Skip to content

Commit adaa1d3

Browse files
authored
Merge pull request #118 from stealthrocket/serialization-readme
Add section describing serialization and its quirks
2 parents 49a1c2f + 5d8f846 commit adaa1d3

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,28 @@ async def transform(msg):
201201
...
202202
```
203203

204+
### Serialization
205+
206+
Dispatch uses the [pickle] library to serialize coroutines.
207+
208+
[pickle]: https://docs.python.org/3/library/pickle.html
209+
210+
Serialization of coroutines is enabled by a CPython extension.
211+
212+
The user must ensure that the contents of their stack frames are
213+
serializable. That is, users should avoid using variables inside
214+
coroutines that cannot be pickled.
215+
216+
If a pickle error is encountered, serialization tracing can be enabled
217+
with the `DISPATCH_TRACE=1` environment variable to debug the issue. The
218+
stacks of coroutines and generators will be printed to stdout before
219+
the pickle library attempts serialization.
220+
221+
For help with a serialization issues, please submit a [GitHub issue][issues].
222+
223+
[issues]: https://github.com/stealthrocket/dispatch-py/issues
224+
225+
204226
## Examples
205227

206228
Check out the [examples](examples/) directory for code samples to help you get

src/dispatch/experimental/durable/function.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from . import frame as ext
1515
from .registry import RegisteredFunction, lookup_function, register_function
1616

17-
TRACE = os.getenv("DURABLE_TRACE", False)
17+
TRACE = os.getenv("DISPATCH_TRACE", False)
1818

1919
FRAME_CLEARED = 4
2020

@@ -114,7 +114,7 @@ def __getstate__(self):
114114
ip, sp, stack = None, None, None
115115

116116
if TRACE:
117-
print(f"\n[DURABLE] Serializing {self}:")
117+
print(f"\n[DISPATCH] Serializing {self}:")
118118
print(f"function = {rfn.fn.__qualname__} ({rfn.filename}:{rfn.lineno})")
119119
print(f"code hash = {rfn.hash}")
120120
print(f"args = {self.args}")

0 commit comments

Comments
 (0)