Skip to content

Commit

Permalink
Revert "Do not always check if __main__ in result when pickling (da…
Browse files Browse the repository at this point in the history
…sk#8443)"

This reverts commit 5c481dd.
  • Loading branch information
fjetter committed Jan 12, 2024
1 parent 9fb41e3 commit 701dbbd
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions distributed/protocol/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,14 @@ def dumps(x, *, buffer_callback=None, protocol=HIGHEST_PROTOCOL):
buffers.clear()
pickler.dump(x)
result = f.getvalue()

if not _always_use_pickle_for(x) and (
if b"__main__" in result or (
CLOUDPICKLE_GE_20
and getattr(inspect.getmodule(x), "__name__", None)
in cloudpickle.list_registry_pickle_by_value()
or (
len(result) < 1000
# Do this very last since it's expensive
and b"__main__" in result
)
):
buffers.clear()
result = cloudpickle.dumps(x, **dump_kwargs)
if len(result) < 1000 or not _always_use_pickle_for(x):
buffers.clear()
result = cloudpickle.dumps(x, **dump_kwargs)
except Exception:
try:
buffers.clear()
Expand Down

0 comments on commit 701dbbd

Please sign in to comment.