Closed jtrain closed 4 years ago
I also don't like always eager. I do this in my tests when I want to run the tasks:
while queue.run_once(): pass
If you really want it you can do it with a subclass, something like:
class EagerAtLeastOnceQueue(AtLeastOnceQueue):
def enqueue(self, *args, **kwargs):
job = super().enqueue(*args, **kwargs)
if settings.ALWAYS_EAGER:
self.run_job(job)
return job
Its worthwhile documenting how to do always eager. I'll put together some docs.
I know celery discourages use of always eager. But I love it, and I always will.
I have written my own version of always eager internally, but it might be nice to add to the library? It is useful during end-to-end testing where you definitely want the thing you are queuing to run during the test.