Skip to content

current_task doesn't work for directly executed tasks #701

Closed
steeve opened this Issue May 30, 2012 · 2 comments

2 participants

@steeve
Celery member
steeve commented May 30, 2012

It's because TaskType.__call__ doesn't push the directly executed task on top the celery.state._task_stack.

Then again, this brings the problem of children tasks: because the current_task.request would be completely new, and the task isn't called via apply (no track in the result backend)...

@ask
Celery member
ask commented Jun 1, 2012

I fixed it here: 20e9776

but the second point is a damn good one :(
I guess it could travel down the stack to find one that does not have request.called_directly
(which is set to False when the worker executes a task)

@ask ask closed this in 5a5ccd9 Jun 1, 2012
@steeve
Celery member
steeve commented Jun 1, 2012

Why not having __call__ be an alias of apply eager ? Maybe your goal is be to transparent when directly calling a task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.