Today I Learned

tags


2022/10/19

that you can easily send asyncio tasks to threads:

#!/usr/bin/env python3
import asyncio
from asyncio.threads import to_thread

async def foo(bar: str):
    asyncio.sleep
    print(bar)

asyncio.run(to_thread(foo, "baz"))