Skip to content

Honour taskbadger_track=False in Celery - #62

Merged
snopoke merged 2 commits into
mainfrom
sk/celery-track-opt-out
Aug 7, 2026
Merged

Honour taskbadger_track=False in Celery#62
snopoke merged 2 commits into
mainfrom
sk/celery-track-opt-out

Conversation

@snopoke

@snopoke snopoke commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

The opt-out documented in python-celery.md has never worked. taskbadger_track was a one-way switch: apply_async unconditionally wrote True over anything the caller passed, and both gates used if not manual_track, which can't distinguish False from absent. There is no configuration in which passing it changed the outcome.

Three places check the header now, and the third is the non-obvious one: canvas tasks never reach task_publish_handler (it bails on celery.* senders), so they're only created in the worker — which is exactly the form the docs use as their example (add.map(...).apply_async(headers=...)).

Also fixes a collision the header form hid: taskbadger_track=False passed the way every other per-call option is passed gets stripped by _get_tb_kwargs into tb_kwargs["track"] and forwarded to create_task, which rejects the unexpected kwarg. Same for a class-level taskbadger_track attribute via the dir(ctask) loop. Both now route to the header instead. A class attribute is inert rather than crashing — it is deliberately not a permanent opt-out, since that overlaps CelerySystemIntegration(excludes=[...]) and would need the check hoisted above the ctask lookup to cover auto-tracked tasks not using base=Task.

Each of the five new tests was confirmed to fail against the pre-fix code.

🤖 Generated with Claude Code

snopoke and others added 2 commits August 7, 2026 10:34
The header could only ever enable tracking: apply_async overwrote it, and the
publish/prerun gates couldn't tell False from absent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@snopoke
snopoke marked this pull request as ready for review August 7, 2026 08:50
@snopoke
snopoke merged commit d051219 into main Aug 7, 2026
6 checks passed
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.

1 participant