python - Realtime Celery Event Monitoring via gevent-socketio -
i'd monitor celery events in realtime gevent-socketio. have following namespace configured, based on examples celery docs.
@namespace('/events') class eventnamespace(basenamespace, broadcastmixin): def listener(self, event): self.state.event(event) # task name sent -received event, , state # keep track of us. task = self.state.tasks.get(event['uuid']) print "got task" self.emit('msg', 'task success: {0}'.format(task.name)) def recv_connect(self): prev = none self.app = celery(broker='amqp://guest:guest@127.0.0.1:49154//') self.state = self.app.events.state() self.app.connection() connection: recv = self.app.events.receiver(connection, handlers={ 'task-succeeded': self.listener, '*': self.state.event, }) recv.capture(limit=none, timeout=none, wakeup=true)
currently, looks if celery event monitor (recv.capture?) blocks emitting events until app shutdown. can see events being emitted through "got task" debug messages , when kill server events spat out consumer @ once.
can guide me on how need modify in order them consumed @ runtime correctly?
i've yet find solution problem when working under django app. however, used flask-socketio within flask create solution seems work celery. further details here: https://github.com/iwootten/celery-socketio
Comments
Post a Comment