Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using contextvars in local.py? #399

Open
akx opened this issue Jun 13, 2023 · 2 comments
Open

Using contextvars in local.py? #399

akx opened this issue Jun 13, 2023 · 2 comments

Comments

@akx
Copy link
Contributor

akx commented Jun 13, 2023

I noticed local.py has a comment saying

asgiref/asgiref/local.py

Lines 29 to 30 in a90aeb9

This doesn't use contextvars as it needs to support 3.6. Once it can support
3.7 only, we can then reimplement the storage more nicely.

which is at odds with the changelog entry for 3.7.0 of this library:

asgiref/CHANGELOG.txt

Lines 14 to 18 in a90aeb9

3.7.0 (2023-05-23)
------------------
* Contextvars are now required for the implementation of Local as Python 3.6
is now no longer a supported version.

(I noticed sync.py uses contextvars.Context, but local.py doesn't. Maybe there was confusion there?)

Either way, what would be the "nicer storage"? Is someone working on it? :)

@andrewgodwin
Copy link
Member

Yeah, we switched sync to use it, but not Local yet. I don't think anyone is actively working on it.

@bluetech
Copy link
Contributor

I looked at this briefly some time ago when looking at Local's performance. IIRC (and I might be misremembering), the difficulty was that contextvars is rooted in a thread local, while Local can be inherited across threads. The semantics are quite different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants