好的,尽管我不确定这是否是解决方案,但我找到了一种解决方法,但是对我有用。监视功能基本上直接连接到代理,并侦听不同类型的事件。我的代码如下所示:
from celery.events import EventReceiverfrom kombu import Connection as BrokerConnectiondef my_monitor: connection = BrokerConnection('amqp://guest:guest@localhost:5672//') def on_event(event): print "EVENT HAPPENED: ", event def on_task_failed(event): exception = event['exception'] print "TASK FAILED!", event, " EXCEPTION: ", exception while True: try: with connection as conn: recv = EventReceiver(conn,handlers={'task-failed' : on_task_failed, 'task-succeeded' : on_event, 'task-sent' : on_event, 'task-received' : on_event, 'task-revoked' : on_event, 'task-started' : on_event, # OR: '*' : on_event }) recv.capture(limit=None, timeout=None) except (KeyboardInterrupt, SystemExit): print "EXCEPTION KEYBOARD INTERRUPT" sys.exit()
这是所有的了。而且我在与正常应用程序不同的过程中运行此程序,这意味着我为我的celery应用程序创建了一个子进程,该子进程仅运行此功能。高温超导
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)