This repository was archived by the owner on Feb 13, 2025. It is now read-only.
forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 61
Add support for PEP 567 context variables to tasklets #239
Comments
+1
sun., 18. apr. 2021 kl. 20:02 skrifaði Anselm Kruis <
***@***.***>:
… Python 3.7 added the context variables and the module *contextvars*. See PEP
567 <https://www.python.org/dev/peps/pep-0567> for details.
Using tasklets it is possible to decorate a plain old callable as a
coroutine (and vice versa). To make such a coroutine fully compatible with
C-Python asyncio tasklets should support PEP 567 context variables. In
C-Python the *current context* is a property of the thread state, that
is, each thread has its own *current context*. In Stackless Python a
thread can have multiple tasklets. Therefore the *current context* must
become a property of the tasklet.
I'm still elaborating details.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#239>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABN3FR3YUENJVFAUOKQSMCLTJM3EDANCNFSM43ESA4RA>
.
|
|
akruis
pushed a commit
that referenced
this issue
May 18, 2021
Use a Py_LOCAL_INLINE function instead of a complicated macro. It is much simpler to debug. In the next commit, we will context switching to this function.
akruis
added a commit
that referenced
this issue
May 18, 2021
Add a private context attribute and appropriate methods to class tasklet. Document the changes in the manual. New methods: tasklet.set_context(context), tasklet.context_run(...) New readonly attribute: tasklet.context_id Add/improve pickling of the context of tasklets. New pickle flag "PICKLEFLAGS_PICKLE_CONTEXT", new undocumented function stackless._tasklet_get_unpicklable_state()
Implemented in 3.7-slp |
akruis
pushed a commit
that referenced
this issue
Jun 5, 2021
Use a Py_LOCAL_INLINE function instead of a complicated macro. It is much simpler to debug. In the next commit, we will context switching to this function. (cherry picked from commit a11414b)
akruis
added a commit
that referenced
this issue
Jun 5, 2021
Add a private context attribute and appropriate methods to class tasklet. Document the changes in the manual. New methods: tasklet.set_context(context), tasklet.context_run(...) New readonly attribute: tasklet.context_id Add/improve pickling of the context of tasklets. New pickle flag "PICKLEFLAGS_PICKLE_CONTEXT", new undocumented function stackless._tasklet_get_unpicklable_state() (cherry picked from commit 032a566)
Merged into main-slp. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Python 3.7 added the context variables and the module contextvars. See PEP 567 for details.
Using tasklets it is possible to decorate a plain old callable as a coroutine (and vice versa). To make such a coroutine fully compatible with C-Python asyncio tasklets should support PEP 567 context variables. In C-Python the current context is a property of the thread state, that is, each thread has its own current context. In Stackless Python a thread can have multiple tasklets. Therefore the current context must become a property of the tasklet.
I'm still elaborating details.
The text was updated successfully, but these errors were encountered: