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

Preserve execution context when running code in ThreadPool #31

Merged
merged 2 commits into from
Dec 26, 2022

Conversation

RobbeSneyders
Copy link
Contributor

Currently contextvars from the ASGI context are not preserved into the WSGI context, which can lead to issues with certain middleware.

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:
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

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.

@abersheeran
Copy link
Owner

Sorry for the lateness, I have been off for the last few days due to COVID-19.

@RobbeSneyders
Copy link
Contributor Author

No worries, was not expecting a response over Christmas anyway. Hope you feel better!

@abersheeran abersheeran merged commit cecacbd into abersheeran:master Dec 26, 2022
@RobbeSneyders
Copy link
Contributor Author

@abersheeran could this be released? We'd like to remove the monkeypatch we have right now in connexion.

@abersheeran
Copy link
Owner

@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.

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

Successfully merging this pull request may close these issues.

2 participants