| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
On GIL-enabled builds, emit a DeprecationWarning when the default implicitly empty threading.Thread() context causes a context variable lookup to differ from the context that a future release will inherit by default.
Context variables created this way will automatically be inherited by the context for new threads, regardless of the setting of `thread_inherit_context`.
We need a per-task copy of decimal.Context() so that mutations are isolated between asyncio tasks and threads using sys.flags.thread_inherit_context. This is done by adding a "depth" counter to PyContext and copying the decimal.Context() instance whenever it doesn't match the depth of the current PyContext.
Documentation build overview6 files changed · ± 6 modified ± Modified |
Sorry, something went wrong.
Change `warnings` and `decimal` to use thread inheritable context vars. This means new threads will start with bindings for these variables from the starter thread, rather than having empty bindings (no matter the value of the thread_inherit_context flag).
|
Closing this since the PRs are going to need some refinement before they are ready for merging. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is a draft PR and is not meant to be merged as it. It shows the result after merging the following changes:
Related discussion is on Discourse.
Reasoning for each change:
In a future release (likely 3.18), we turn thread_inherit_context on by default. Then, ContextVar.thread_inheritable() and ContextVar() do the same thing. We can just leave thread_inheritable() as a soft-deprecated alias.