Skip to main content

Taskiq Deduplication

Redis-backed deduplication middleware for Taskiq that prevents duplicate tasks from being queued or executed concurrently.

CI codecov ty uv Ruff Python 3.10+ License: MIT


Documentation: https://taskiq-deduplication.d3vyce.fr

Source Code: https://github.com/d3vyce/taskiq-deduplication


Installation

uv add "taskiq-deduplication"

Quick Start

from taskiq_redis import ListQueueBroker
from taskiq_deduplication import RedisDeduplicationMiddleware, DuplicateTaskError

broker = ListQueueBroker("redis://localhost:6379").with_middlewares(
    RedisDeduplicationMiddleware(redis_url="redis://localhost:6379"),
)


@broker.task
async def send_report(user_id: int) -> None: ...


# First dispatch acquires the lock — succeeds.
await send_report.kiq(user_id=42)

# Second dispatch while the first is queued or running — raises.
try:
    await send_report.kiq(user_id=42)
except DuplicateTaskError:
    pass  # already queued or running

Features

  • Sender-side deduplication — rejects duplicate tasks at dispatch time via a Redis lock, before they reach the broker.
  • Handle to the winning task — a rejected caller gets the winner's task_id on the error, so it can await the winner's result instead of re-kicking.
  • Atomic lock release — lock is released on completion or error via a Lua check-and-delete; only the owning task can release its lock.
  • Configurable TTL — set a global default or override per task with the deduplication_ttl label.
  • Lock heartbeat — a background task re-extends the lock TTL while the task runs, so long-running tasks keep their lock instead of expiring mid-execution and admitting a duplicate.
  • Explicit lock key — pin any task to a fixed Redis key with deduplication_key, bypassing fingerprint computation entirely.
  • Partial fingerprint — deduplicate on a subset of kwargs with deduplication_key_fields, ignoring irrelevant arguments (positional arguments are excluded).
  • Per-task opt-out — disable deduplication for individual tasks with the deduplication label.
  • Startup resilience — automatic reconnection with exponential backoff if Redis is unavailable at broker startup.
  • Fail-open mode — opt in with fail_open to keep dispatching tasks when Redis is unreachable at runtime, trading deduplication for availability.

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Metadata

Release files for taskiq-deduplication 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taskiq-deduplication 1.2.0
File Size Uploaded
taskiq_deduplication-1.2.0.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for taskiq-deduplication 1.2.0
File Interpreter ABI Platform
taskiq_deduplication-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.1 kB

Release files / taskiq_deduplication-1.2.0.tar.gz

Download URL taskiq_deduplication-1.2.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
492eb61be9908f7382d303e2b3d1d6459f6234d235acd5939986c60b2030e707
BLAKE2b-256 checksum
How to use checksums
5e05e5c8a7df113615b1c2378a88f88122831b6ae20874eaaf0e6eca9c6d019d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release files / taskiq_deduplication-1.2.0-py3-none-any.whl

Download URL taskiq_deduplication-1.2.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
785c2c7049f3bfb931f4af4adf3c93a803c23a915e4df820b9d641f0c1a4ae12
BLAKE2b-256 checksum
How to use checksums
f19411056898c29aaaa46a0634b07e6278264c633b8557093685e8554b1dc87a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page