from celery import Celery app = Celery('tasks', broker='redis://localhost', backend='redis://localhost') # for demo purpose restrict the number of prefetched tasks to 1 # this effectively limits the number of rate limited tasks submitted to 4 # before the worker gets blocked. Leaving it at the default value (4) means # you need 4 * 4 = 16 tasks before the worker stops receiving new tasks # That is the number of rate limited tasks required to block the worker # increases however it does not solve the problem (though setting the prefetch # multiplier to some very large number e.g. sys.maxint may be a work around # in some scenarios) # https://docs.celeryproject.org/en/stable/userguide/configuration.html#worker-prefetch-multiplier app.conf.worker_prefetch_multiplier = 1 @app.task def A(x, y): return x + y @app.task def B(x, y): return x - y