Closed chriso closed 7 months ago
One question I would like to validate is if dill supports custom serialization via reduce, which would be needed to benefit from changes like https://github.com/encode/httpx/pull/3108
Let's hold off on merging this until we have a better idea of the capabilities and trade-offs of dill
, or until we have more users running into serialization issues and need a short-term fix. I'd like to explore whether pickle
's dispatch tables could be used to solve https://github.com/stealthrocket/dispatch-py/issues/94, or whether dill
provides an alternative solution there.
Other question that came to mind, should we use replace other use of pickle with dill (for example)?
Let's stick with pickle
for now in the dispatch.proto
file, since we're only using it to serialize input and output values which are less likely to include the "exotic" objects that dill
is able to serialize.
This is out of sync. I'll reboot if/when necessary.
This PR introduces dill for serialization of coroutine state, replacing pickle from the standard library.
From the dill README:
Dispatch supports serializing coroutines (including generators) and their frames, so that's a non-issue.
The fact that dill can serialize cell vars means that this PR fixes https://github.com/stealthrocket/dispatch-py/issues/117.
One thing I like about dill is the built-in tracing. The
DISPATCH_TRACE
environment variable can be used to enable dill tracing. Below is an example trace when serializing the state of the functions from https://github.com/stealthrocket/dispatch-py/issues/117.Example trace:
``` ┬ T4:The library also provides tooling for inspecting state offline, which may come in handy in future.