celery-batches
celery-batches copied to clipboard
Add events for Flower
Add "task-*" events so we can monitor the queue with Flower.
Any chance that tests could be added for this?
Is there a good way to test if a signal has been sent with pytest? I tried:
class TaskMonitor:
def __init__(self):
self.tasks_received = 0
self.tasks_started = 0
self.tasks_suceeded = 0
def on_task_received(self, event):
self.tasks_received += 1
def on_task_started(self, event):
self.tasks_started += 1
def on_task_suceeded(self, event):
self.tasks_suceeded += 1
tm = TaskMonitor()
recv = celery_app.events.Receiver(connection, handlers={
'task-received': tm.on_task_received,
'task-started': tm.on_task_started,
'task-suceeded': tm.on_task_suceeded,
'*': tm.on_other
})
but I can't seem to get it to work. If you can help me figure out how to get it to listen for events in a pytest, I can implement it. I tested it in Flower, and it seems to work, but I'm not sure how to get the internals to work for a unit test.
Some of the tests use the SignalCounter class to do this (it is a bit hacky, but I haven't managed to figure out a better way to do it).
See also #70.
@gersh Shout when you think this is ready for review again!
You should be able to run the lints locally manually by running the same commands as CI:
https://github.com/clokep/celery-batches/blob/59cc04f9c0220581fd84a1116cd390ddc6a799ec/.github/workflows/main.yml#L23-L39
@clokep I think I fixed the lint issues.
@clokep I fixed all the lint issues.