Skip to content

Instantly share code, notes, and snippets.

View peterrus's full-sized avatar
🐧

peterrus peterrus

🐧
View GitHub Profile
@peterrus
peterrus / flask-websocket-log-stream.py
Created March 13, 2022 11:56
Runs a scheduled job in a background thread using APScheduler and streams it's output to a web client using websockets.
# Runs a scheduled job in a background thread using APScheduler and streams
# it's output to a web client using websockets. Communication between the Flask
# thread and APScheduler thread is being done through (blinker) signals.
#
# Install dependencies (preferably in your virtualenv)
# pip install flask apscheduler sqlalchemy blinker flask-socketio simple-websocket
# and then run with:
# python this_script.py
from time import sleep