Skip to content

Instantly share code, notes, and snippets.

View shbatm's full-sized avatar

shbatm shbatm

View GitHub Profile
@dmfigol
dmfigol / asyncio_loop_in_thread.py
Last active November 14, 2024 08:52
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable