Skip to content

Add manual task acknowledgement#637

Open
vvanglro wants to merge 1 commit into
taskiq-python:masterfrom
vvanglro:feature/manual-task-ack
Open

Add manual task acknowledgement#637
vvanglro wants to merge 1 commit into
taskiq-python:masterfrom
vvanglro:feature/manual-task-ack

Conversation

@vvanglro

@vvanglro vvanglro commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Why

Some broker backends support explicit message acknowledgement, but taskiq currently only lets workers choose a fixed automatic acknowledgement point: when received, when executed, or when saved.

For some tasks, acknowledgement needs to happen after an application-level durable action is completed, but before the whole task finishes. Examples include committing an external transaction, persisting an idempotency marker, or coordinating with another system where the task code knows the correct acknowledgement boundary better than the worker.

This change adds an explicit manual acknowledgement mode so advanced users can acknowledge from inside the task through Context.ack(), while preserving the existing automatic acknowledgement behavior for all other modes.

Summary

  • add manual acknowledgement type
  • expose Context.ack(), Context.is_ackable, and Context.is_acked for task-level manual acknowledgement
  • keep automatic acknowledgement idempotent through a shared ack controller
  • document manual acknowledgement and add receiver/ack parser tests

Compatibility

Existing acknowledgement modes are unchanged. Manual acknowledgement only works for brokers that yield AckableMessage; otherwise Context.ack() raises a clear runtime error.

Tests

  • env -u PYTHONPATH -u VIRTUAL_ENV .venv/bin/python -m pytest -q
  • env -u PYTHONPATH -u VIRTUAL_ENV .venv/bin/python -m ruff check .
  • env -u PYTHONPATH -u VIRTUAL_ENV .venv/bin/python -m black --check .

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.29730% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.20%. Comparing base (fe92683) to head (d6af7d6).

Files with missing lines Patch % Lines
taskiq/context.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #637      +/-   ##
==========================================
+ Coverage   80.02%   80.20%   +0.18%     
==========================================
  Files          69       69              
  Lines        2548     2577      +29     
==========================================
+ Hits         2039     2067      +28     
- Misses        509      510       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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