Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not always check if __main__ in result when pickling #8443

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions distributed/protocol/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,19 @@
buffers.clear()
pickler.dump(x)
result = f.getvalue()
if b"__main__" in result or (

if not _always_use_pickle_for(x) and (
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
)
):
if len(result) < 1000 or not _always_use_pickle_for(x):
buffers.clear()
result = cloudpickle.dumps(x, **dump_kwargs)
buffers.clear()
result = cloudpickle.dumps(x, **dump_kwargs)

Check warning on line 82 in distributed/protocol/pickle.py

View check run for this annotation

Codecov / codecov/patch

distributed/protocol/pickle.py#L81-L82

Added lines #L81 - L82 were not covered by tests
except Exception:
try:
buffers.clear()
Expand Down
Loading