lundi 19 novembre 2018

Synchronously work off all the pending tasks when using the in-memory broken in Celery

For testing purposes, I'm using the in-memory Celery broker: "memory://localhost/". I can start a worker that will execute these tasks like this:

app = Celery('celery_app')
worker = app.Worker(app=app, pool='solo', concurrency=1)
thread = threading.Thread(target=worker.start)
thread.daemon = True
thread.start()

but how can I have more control over it? I want to execute all the tasks, blocking/synchronously, so that my tests can make strong assertions about the state of the system before and after running the tasks.

I am aware that if tasks generate more tasks, this could last forever.

Aucun commentaire:

Enregistrer un commentaire