You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The contextvars module, from PEP 567, is necessary to upgrade asyncio (and decimal) to CPython 3.8. I started #2950 to implement contextvars, but the PR has since stalled. (@DimitrisJim urged me to open this issue.)
Detailed Explanation and Rationale
PEP 567, implemented in CPython 3.7, introduced the contextvars module and context variables, which are conceptually similar to thread-local variables. However, unlike thread-local variables, context variables correctly support asynchronous code. Following that implementation, the asyncio and decimal modules were re-written to take advantage of this new capability. As part of our endeavors to get as much of the codebase covered by the CPython test suite as possible (see #1671), and out of a desire support CPython 3.8 or later (see the README), I think it's necessary to add the test_asyncio module to the CPython test suite. The addition of the CPython 3.8 version of test_asyncio would benefit from upgrading the asyncio module itself to that same version. (@coolreader18 and I have noticed that test failures were often alleviated by upgrading the relevant Python module.) However, asyncio has a dependency — contextvars — that we don't have yet. Accordingly, I have started a draft PR (#2950) to implement this module here, but I got stymied when I was drafting the Rust implementation because I am unfamiliar with how RustPython deals with thread safety. For context, here are the parts of the C implementation that I think are relevant:
Summary
The
contextvars
module, from PEP 567, is necessary to upgradeasyncio
(anddecimal
) to CPython 3.8. I started #2950 to implementcontextvars
, but the PR has since stalled. (@DimitrisJim urged me to open this issue.)Detailed Explanation and Rationale
PEP 567, implemented in CPython 3.7, introduced the
contextvars
module and context variables, which are conceptually similar to thread-local variables. However, unlike thread-local variables, context variables correctly support asynchronous code. Following that implementation, theasyncio
anddecimal
modules were re-written to take advantage of this new capability. As part of our endeavors to get as much of the codebase covered by the CPython test suite as possible (see #1671), and out of a desire support CPython 3.8 or later (see the README), I think it's necessary to add thetest_asyncio
module to the CPython test suite. The addition of the CPython 3.8 version oftest_asyncio
would benefit from upgrading theasyncio
module itself to that same version. (@coolreader18 and I have noticed that test failures were often alleviated by upgrading the relevant Python module.) However,asyncio
has a dependency —contextvars
— that we don't have yet. Accordingly, I have started a draft PR (#2950) to implement this module here, but I got stymied when I was drafting the Rust implementation because I am unfamiliar with how RustPython deals with thread safety. For context, here are the parts of the C implementation that I think are relevant:Unresolved Questions
PyContext
(defined inpyobject.rs
), and does it have any bearing on the scope of PEP 567?Context
object relate to a thread in RustPython?The text was updated successfully, but these errors were encountered: