Skip to content

feature: add celery_beat_task header in task options #9702

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alirafiei75
Copy link
Contributor

Description

This pull request adds a new custom header celery_beat_task to task options, enabling reliable identification of tasks originating from Celery Beat. This enhancement addresses the challenge discussed in one of django-celery-beat issues (number 854).

Changes

  • Added celery_beat_task header to task options when tasks are sent by Celery Beat
  • Added unit tests for the new header

Related Issues

celery/django-celery-beat#854

Copy link

codecov bot commented May 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.31%. Comparing base (5c1a13c) to head (f08af52).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9702   +/-   ##
=======================================
  Coverage   78.30%   78.31%           
=======================================
  Files         153      153           
  Lines       19127    19129    +2     
  Branches     2533     2533           
=======================================
+ Hits        14978    14980    +2     
  Misses       3860     3860           
  Partials      289      289           
Flag Coverage Δ
unittests 78.28% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@auvipy auvipy added this to the 5.7.0 milestone May 13, 2025
@auvipy auvipy requested a review from Copilot May 18, 2025 04:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new custom header, celery_beat_task, into task options so that tasks dispatched by Celery Beat can be reliably identified.

  • Added tests in t/unit/app/test_beat.py to verify the header is correctly injected and that existing headers are preserved.
  • Updated celery/beat.py to merge the new header into task options during task dispatch.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
t/unit/app/test_beat.py Added unit tests for header injection and preservation.
celery/beat.py Enhanced apply_async to include the celery_beat_task header.

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 this pull request may close these issues.

2 participants