Skip to content

Instantly share code, notes, and snippets.

View rwang0417's full-sized avatar

Ran Wang rwang0417

  • Texas A&M University
  • College Station, TX
View GitHub Profile
@dmfigol
dmfigol / asyncio_loop_in_thread.py
Last active July 10, 2024 12:43
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