-
-
Notifications
You must be signed in to change notification settings - Fork 378
Closed
Description
trio.Cancelled can't be constructed directly so it can't be pickled. Usually this is fine as no one needs to pickle and move around a trio.Cancelled object. But sometimes it gets trapped in some other exception's __context__ or __cause__.
One example is
async def test():
with trio.fail_after(0.1):
await trio.sleep(5)
try:
trio.run(test)
except trio.TooSlowError as e:
print(e.__context__)(By default __context__ of an exception doesn't get pickled but tblib.pickling_support adds it, which I think is reasonable?)
And now we can't pickle this TooSlowError anymore.
Here's the full example:
from tblib import pickling_support
pickling_support.install(trio.TooSlowError)
async def test():
with trio.fail_after(0.1):
await trio.sleep(5)
try:
trio.run(test)
except trio.TooSlowError as e:
b = e
import pickle
pickle.loads(pickle.dumps(b))Can we add pickle support for trio.Cancelled?
noahbkim and Hnasar
Metadata
Metadata
Assignees
Labels
No labels