-
Notifications
You must be signed in to change notification settings - Fork 61
Separate pickling of generators, coroutines and asynchronous generators #139
Comments
Currently I have no time and I don't want to delay the first Stackless 3.6 release any further. |
Meantime I'm working on Stackless 3.7. Upstream commit fc2f407 (bpo-32591) adds an additional field to PyCoroObject. Therefore stackless/Stackless/pickling/prickelpit.c Line 1560 in 8f908ec
It's now finally time to separate the pickling code for generators, coroutines and asynchronous generators. |
The pickling code is now separated (commit 94d5fad). Pickling of asynchronous generators turned out to be not trivial, because they have - at C-level - the attribute "ag_finalizer". This attribute is more or less a cache for a global variable of the async-framework. |
The outcome of this merge does not compile. Stackless issue #139 will fix this.
Since upstream commit fc2f407 (bpo-32591) the memory layout of generators and coroutines differs. Therefore it is no longer feasible to share the pickling code. This refactor the common parts of the reduce/setstate implementation into support methods and support the new coroutine attribute cr_origin.
The new function compute_cr_origin(int origin_depth) inspects stack frames. Modify it to ignore C-frames. This fixes a segfault in test.test_asyncio.test_events.EPollEventLoopTests.test_sock_client_ops
Add the new attribute "cr_origin" to the copy-test.
…reterState Resize flags and reorder them to avoid padding. This is a preparation for adding another flag field for pickle related flags.
Add the flags and methods stackless.pickle_flags() and stackless.pickle_flags_default() to get or set them. Currently only one flag is defined in prickelpit.h. It will be used by the next commit.
Update the documentation regarding pickling. More to come.
Stackless now pickles asynchronous generators. Read the documentation about Stackless pickling for details.
Stackless now pickles awaitable objects of type PyAsyncGenASend or PyAsyncGenAThrow (see PEP 525).
A short overview over the commits:
There's another auxiliary type _PyAsyncGenWrappedValue. I looked at the code and I'm fairly sure that objects of this type can't be seen by Python code. |
Add the global variable gen_exhausted_asyncgen to the list of ignored globals. It is a constant singleton.
Commit 3ea77a9 merges Asynchronous Generators into branch master-slp. Perhaps Stackless should learn how to pickle them and related types. This would be in line with the pickling support for generators and coroutines.
The text was updated successfully, but these errors were encountered: