Skip to content

Instantly share code, notes, and snippets.

View pangyuteng's full-sized avatar

pangyuteng

View GitHub Profile
@pangyuteng
pangyuteng / cancel.py
Last active June 17, 2022 17:14
async demo of workers being paused and resumed to consume jobs from queue with Celery, Rabbitmq, os Windows.
#cancel consuming from queue
import traceback
from foo import app
import celery
ds = []
activate =app.control.inspect().active()
while activate is None:
activate =app.control.inspect().active()
@pangyuteng
pangyuteng / AsyncNotify.py
Created May 11, 2017 15:39 — forked from pfote/AsyncNotify.py
postgres LISTEN/NOTIFY psycopg2/twisted
import psycopg2
import psycopg2.extensions
from select import select
from twisted.internet import threads
class AsyncNotify():
"""
based on http://divillo.com/, adapted to newer psycopg version
Class to trigger a function via PostgreSQL NOTIFY messages.