Skip to content

sync_to_async does not find root thread inside a task #214

@andrewgodwin

Description

@andrewgodwin

When you use create_task (or any way of making a coroutine not through asgiref), and the root thread is synchronous, then sync_to_async in thread-sensitive mode will use the root thread outside of tasks and a single, specific new thread inside of tasks, ruining the thread-sensitive guarantee.

Instead, we should make sync_to_async always first look for an executor on the root thread and, if it finds it, use that to run code.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions