Skip to content

Allow middlewares to skip sending a task with SkipSendError - #690

Open
d3vyce wants to merge 1 commit into
taskiq-python:masterfrom
d3vyce:feat/skip-send-error
Open

d3vyce wants to merge 1 commit into
taskiq-python:masterfrom
d3vyce:feat/skip-send-error

Conversation

@d3vyce

@d3vyce d3vyce commented Sep 29, 2026

Copy link
Copy Markdown

Middlewares have no clean way to drop a task in pre_send (#271). For example, taskiq-deduplication has to raise DuplicateTaskError out of kiq(), so callers need try/except and a losing scheduler logs a traceback every tick.

This adds SkipSendError, which a middleware can raise from pre_send to drop the task. kiq() then:

  • doesn't send the message to the broker,
  • skips the remaining pre_send hooks and all post_send hooks,
  • returns normally instead of raising.

If the error carries a task_id, the returned AsyncTaskiqTask points to that task, so the caller can follow the existing task's status and result. Without one, it points to the dropped message, and waiting for its result will time out.

This branch has not been deployed

No deployments
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