(celery) :Run task in a specific worker? -
i have many workers different server in celery,(the below picture shows)
and many tasks:
@task(name="task1") def task1(): ....... @task(name="task2") def task2(): ......
i want run "task1" on "celery@40.218testlab_website" worker. how should config?
you can give workers different names, assign each worker read specific queue when running, aka:
celery -a tasks -n worker1 -q queue1 --loglevel=info celery -a tasks -n worker2 -q queue2 --loglevel=info ...
and add router, example:
def route_task(name, args, kwargs, options, task=none, **kw): if name == 'task1': return 'queue1' elif name == 'task2': return 'queue2' return none
note, implementation depends on celery version run (i'm using 3.1) - changed little in 4. there simpler router in link i've added (in configuration) - check out.
good luck
Comments
Post a Comment