Skip to content
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

Celery: Unhanded exception in task_prerun_callback #731

Closed
tony opened this issue Feb 24, 2022 · 9 comments · Fixed by #732
Closed

Celery: Unhanded exception in task_prerun_callback #731

tony opened this issue Feb 24, 2022 · 9 comments · Fixed by #732

Comments

@tony
Copy link
Contributor

tony commented Feb 24, 2022

Using celery-batches 0.2.0, celery 4.4.7, python 3.10, redis backend

What happens: Request with missing delivery_info raises error. This bubbles up to sentry, another tool.

Expected behavior: Drop the trace is unless error reporting is enabled on scout-apm.

AttributeError: 'NoneType' object has no attribute 'get'
  File "celery/utils/dispatch/signal.py", line 288, in send
    response = receiver(signal=self, sender=sender, **named)
  File "scout_apm/celery.py", line 60, in task_prerun_callback
    tracked_request.tag("is_eager", delivery_info.get("is_eager", False))
{
args: [
[
<celery_batches.SimpleRequest object at 0x7fbd1f2f9720>, 
<celery_batches.SimpleRequest object at 0x7fcd15dd65e0>, 
<celery_batches.SimpleRequest object at 0x7fad18d6fa30>, 
<celery_batches.SimpleRequest object at 0x7fed14d6e1a0>, 
<celery_batches.SimpleRequest object at 0x7fad13d6e230>
]
], 
kwargs: {}, 
sender: <@task: project.app.jobs.track_happening of project at 0x2faa2c2713f0 (v2 compatible)>, 
signal: <Signal: task_prerun providing_args={'args', 'kwargs', 'task', 'task_id'}>, 
task_id: '684c6b14-4349-42e7-bc8d-4d410bceb1c9'
}
tony added a commit to tony/scout_apm_python that referenced this issue Feb 24, 2022
@tim-schilling
Copy link
Collaborator

Thanks for the issue Tony. Is this occurring for all tasks that use celery-batches?

@tim-schilling
Copy link
Collaborator

@tony Which broker are you using with celery?

@tony
Copy link
Contributor Author

tony commented Feb 24, 2022

@tim-schilling

broker: Redis

json serializer for tasks and results.

Thanks for the issue Tony. Is this occurring for all tasks that use celery-batches?

Yes. Also I believe the underlying cause is likely the underlying cause is on my end (celery tasks complete fine)

I can provide app id over email at your request

@tim-schilling
Copy link
Collaborator

That's alright. I was curious if it was another broker that may be eating it. I suspect what you have is what we need to do. I'm going to change it over to getattr to match the rest of the function, add a test and some docs.

@tony
Copy link
Contributor Author

tony commented Feb 24, 2022

@tim-schilling feel free to close out #732 if your getattr way of doing it supersedes it.

@tony
Copy link
Contributor Author

tony commented Mar 2, 2022

@tim-schilling Do you have any updates on this? This is an issue preventing us from enabling scout-apm background tasks on in our app

@tim-schilling
Copy link
Collaborator

@tony not currently. I will work on it tonight. Thank you for clarifying its importance.

@tim-schilling
Copy link
Collaborator

@tony This has been released in v2.24.2. Thank you for the bug report!

@tony
Copy link
Contributor Author

tony commented Mar 3, 2022

@tim-schilling Based on my tests 2.42.2 is working well.

all background tasks collect superbly, including the one that was problematic (that ostensibly skips the delivery_info block)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants