(celery) :Run task in a specific worker? -


i have many workers different server in celery,(the below picture shows) enter image description here

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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -