Skip to content

Commit

Permalink
rewrite the thing
Browse files Browse the repository at this point in the history
  • Loading branch information
fjetter committed Jan 9, 2024
1 parent ee7c1c5 commit c5f1379
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions distributed/protocol/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ def dumps(x, *, buffer_callback=None, protocol=HIGHEST_PROTOCOL):
buffers.clear()
pickler.dump(x)
result = f.getvalue()
if (

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 and not _always_use_pickle_for(x))
# this is pretty expensive so check very last
and b"__main__" in result
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)

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
Expand Down

0 comments on commit c5f1379

Please sign in to comment.