Reputation: 43
i need async call subtasks in celery to another worker (on another machine) like this:
#db.py
@task()
def query(x,y):
...something
return z
#worker2.py
@task()
def main(x,y):
result=db.query.async((x,y), queue='db')
try:
a=result.get(timeout=5)
except celery.exceptions.TimeoutError:
....
But i get warning when starting worker: RuntimeWarning: Never call result.get() within a task!
How can i call async tasks from another task? I wont'n use chain, chord etc.
Upvotes: 2
Views: 1009
Reputation: 946
You never want to block one task to wait for another, so the correct approach is to use chain:
db.py
@task()
def query(x, y):
...something
return z
#worker2.py
@task()
def main(resultFromQuery, x, y):
a = resultFromQuery.get(timeout=5)
...
res = chain(query.s(x,y), main.s(x,y));
res.get()
Upvotes: 1