Skip to content

Instantly share code, notes, and snippets.

@sefgit
Created March 21, 2025 16:43
Show Gist options
  • Save sefgit/8378d840c249028729c5c652d1eb36ed to your computer and use it in GitHub Desktop.
Save sefgit/8378d840c249028729c5c652d1eb36ed to your computer and use it in GitHub Desktop.
asyncio thread
# https://daily.dev/blog/get-to-know-asynchio-multithreaded-python-using-asyncawait
import asyncio
import threading
async def main():
result = await asyncio.to_thread(blocking_func)
print(result)
asyncio.run(main())
fut = asyncio.run_coroutine_threadsafe(coro_func(), loop)
result = fut.result()
# https://daily.dev/blog/get-to-know-asynchio-multithreaded-python-using-asyncawait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment