Skip to content

Instantly share code, notes, and snippets.

View sap2me's full-sized avatar
🏠
Working from home

Andrii Sapronov sap2me

🏠
Working from home
View GitHub Profile
@dmfigol
dmfigol / asyncio_loop_in_thread.py
Last active November 24, 2025 13:16
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
@pgjones
pgjones / app.py
Last active January 15, 2020 15:00
flask-sockets example requires: Flask, Flask-Sockets, Flask-SocketIO
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template_string
from flask_sockets import Sockets
import json
app = Flask(__name__)
sockets = Sockets(app)
template = """