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

SyncToAsync no longer thread-sensitive #482

Open
markgajdosik opened this issue Oct 15, 2024 · 2 comments
Open

SyncToAsync no longer thread-sensitive #482

markgajdosik opened this issue Oct 15, 2024 · 2 comments

Comments

@markgajdosik
Copy link

3.8.x no longer follows the thread-sensitive principle of a single executor. I have an application that worked without issues on 3.7.2, but since upgrading to Python 3.12, I also upgraded asgiref to 3.8.1 as it adds support for this version of Python. It's a REST API client powered by aiohttp that pulls data into the database.

Despite the fact that every call is thread_sensitive=True, I get deadlocks about 80% of the time. When I log the ID of the executor it wants to use in SyncToAsync.__call__, I am seeing that many executors are being spun up and used to run sync code in an async loop.

I'll try to investigate some more & provide more details, but my time on this ticket is limited and I am leaning towards a perhaps risky downgrade to more stable 3.7.2, even with Python 3.12.

@carltongibson
Copy link
Member

@markgajdosik Thanks for the report.

It's not really actionable as is. Some kind of minimal reproduce is probably needed to be able to say anything specific.

Can you try the main branch? Possibly #478 is related.

@markgajdosik
Copy link
Author

Hi @carltongibson, I thought you might say that. I now managed to work around the issue by creating a wrapper around SyncToAsync which passes thread_sensitive=False and own single thread executor.

I'll try what you suggested and will think of a way to separate the issue into something you can use to reproduce the problem.

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

2 participants