asgiref
asgiref copied to clipboard
[3.8 regression] Deadlock with `async_to_sync` → `sync_to_async` → `async_to_sync` → `create_task` → `sync_to_async`
This code, minimized from the Zulip server, worked in asgiref 3.7.2, but deadlocks in 3.8.0, 3.8.1, and current main (abc69a054aa440ef42c939b5a197df05c3ad48d2). A Git bisection implicates d920c3c44f59ef037be3a09a41a5640014cfb1e2 as the first broken commit:
- #367, cc @jthorniley
import asyncio
from asgiref.sync import async_to_sync, sync_to_async
async def inner() -> asyncio.Task[None]:
return asyncio.create_task(sync_to_async(print)("inner"))
async def main() -> None:
task = await sync_to_async(async_to_sync(inner))()
await task
async_to_sync(main)()
Any updates on this bug? Thanks!
@bartekgruszka Trying out the branch from #494 would be helpful. (See related discussions from three of you want to dig deeper.)