-
Notifications
You must be signed in to change notification settings - Fork 20
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
Preserve execution context when running code in ThreadPool #31
Preserve execution context when running code in ThreadPool #31
Conversation
330090e
to
6347403
Compare
6347403
to
81464b6
Compare
a2wsgi/wsgi.py
Outdated
import os | ||
import sys | ||
import typing | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
from .types import Environ, Message, Receive, Scope, Send, StartResponse, WSGIApp | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new version of a2wsgi only supports above 3.7, so we can use contextvars directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, didn't know that.
I checked the pyproject.toml which still includes 3.6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that was an oversight on my part.
Sorry for the lateness, I have been off for the last few days due to COVID-19. |
No worries, was not expecting a response over Christmas anyway. Hope you feel better! |
@abersheeran could this be released? We'd like to remove the monkeypatch we have right now in connexion. |
https://pypi.org/project/a2wsgi/1.7.0/ Thanks for your contribution, this PR is now released in 1.7. |
Currently contextvars from the ASGI context are not preserved into the WSGI context, which can lead to issues with certain middleware.