Skip to content

Instantly share code, notes, and snippets.

@ingoogni
ingoogni / hbmqttcherrypy.py
Last active March 6, 2019 06:16
Cherrypy MQTT HBMQTT plugin
#https://stackoverflow.com/questions/26270681/can-an-asyncio-event-loop-run-in-the-background-without-suspending-the-python-in
import asyncio
import threading
import cherrypy
from cherrypy.process import plugins
from hbmqtt.client import MQTTClient, ClientException
from hbmqtt.mqtt.constants import QOS_1, QOS_2
@ingoogni
ingoogni / CherryPy_PGrepub.py
Last active October 1, 2017 16:54
CherryPy PostgreSQL pgpubsub
import threading
import pgpubsub
import cherrypy
from cherrypy.process import plugins
class PGrepub(plugins.SimplePlugin):
"""
Plugin that listens to Postresql notification channels and publishes
the payload unmodified to a channel on the CherryPy bus.
@ingoogni
ingoogni / cherrypy_SSE.py
Last active June 6, 2024 17:17
CherryPy SSE / Server-Sent Events, Eventsource helpers to publish data from cherrypy's pub/sub bus
import threading
import cherrypy
from cherrypy.process import plugins
class Portier(threading.Thread):
"""
The Doorman (Portier) detects changes of message by listening to the
subscribed channel, opens 'the door' as a message appears, yield it
and closes the door once trough.