Reputation: 1499
how can I tell from within a celery task, if the task has been called from just the apply method, rather then the apply_async ( or delay ).
Upvotes: 3
Views: 2059
Reputation: 122376
You can look at the is_eager
or called_directly
attributes of self.request
within the task (the documentation currently isn't very clear on the difference):
@app.task(bind=True)
def task_with_context(self, *args, **kwargs):
print self.request.is_eager, self.request.called_directly
Upvotes: 11