-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error info for failure when task has no request stack. #7173
Comments
Hey @stevecj 👋, We also offer priority support for our sponsors. |
@stevecj how did you solve the problem? I am experiencing this as well. All of my tasks are shared tasks, however the ones that are causing this are being autodiscovered from another package. |
Since Celery is crashing, we should treat this as a bug. Could you please provide the relevant lines that caused the issue? |
On further investigation, this is not crashing celery and I am not sure that I am experiencing the exact same issue. Here's a stack trace in case anyone thinks otherwise:
Something is causing |
Here's a minimal reproducible example: from celery import Celery, Task
app = Celery()
class CustomTask(Task):
name = "custom_task"
def run(self):
return 'hello'
app.tasks.register(CustomTask()) # broken, AttributeError: 'NoneType' object has no attribute 'push'
# app.register_task(CustomTask()) # fixed, no error The bug/regression appears for the first time in v5.2.0b1 and is not present in 5.1.2 for me. Again it only applies to class-based tasks, and it has everything to do with what method is used to register the task. |
Checklist
for similar or identical enhancement to an existing feature.
for existing proposed enhancements.
to find out if the if the same enhancement was already implemented in the
master branch.
(If there are none, check this box anyway).
Brief Summary
Handle the exception that occurs in
build_tracer()
in celery/app/trace.py when a task hasNone
as the value of itsrequest_stack
attribute, and raise an exception with a message that says what task had the failure.The reason I am asking for this is that I just had to fight with a problem during an upgrade to celery 5.2.1 in a Django app. I had thought that all of our tasks were defined using
@shared_task
, but it turns out one of them was defined as a subclass ofTask
and then registered. The way that was done does not work right in celery 5.2.1, and celery crashed as a result. The error output was useless, and I had to edit the installed celery code to add instrumentation to help me track it down.The code that I patched in celery/concurrency/prefork.py to tell me what task was the problem:
Once I knew which task it was, I was able to solve the problem. It would be nice not to have to hand-edit the celery code to get that information though.
The text was updated successfully, but these errors were encountered: