Taskiq Deduplication
Redis-backed deduplication middleware for Taskiq that prevents duplicate tasks from being queued or executed concurrently.
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_idon 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_ttllabel. - 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
deduplicationlabel. - Startup resilience — automatic reconnection with exponential backoff if Redis is unavailable at broker startup.
- Fail-open mode — opt in with
fail_opento 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)
| File | Size | Uploaded | |
|---|---|---|---|
| taskiq_deduplication-1.2.0.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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