Skip to main content

Production-ready utilities for FastAPI applications

Project description

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 queue lock, before they reach the broker.
  • Worker-side detection — logs concurrent duplicate executions without raising, keeping SmartRetryMiddleware safe from retry storms.
  • Configurable TTL — set a global default or override per task with the deduplication_ttl label.
  • 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.
  • Per-task opt-out — disable deduplication for individual tasks with the deduplication label.

License

MIT License - see LICENSE for details.

Contributing

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taskiq_deduplication-1.0.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskiq_deduplication-1.0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file taskiq_deduplication-1.0.1.tar.gz.

File metadata

  • Download URL: taskiq_deduplication-1.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for taskiq_deduplication-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4e5949abe6334f6fd6ef88abfac52e4756fd1724604e218326dc8375514526a8
MD5 e4ec6876111ab58b9fcf4f90b6d64c72
BLAKE2b-256 4c9a4a0bfb9394813284ecf55216893c6b2e9f5125403aa9a00942ce2893aafb

See more details on using hashes here.

Provenance

The following attestation bundles were made for taskiq_deduplication-1.0.1.tar.gz:

Publisher: build-release.yml on d3vyce/taskiq-deduplication

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file taskiq_deduplication-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for taskiq_deduplication-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b15aaeabec716693bdea758efda8b92e642e064a760293426f1794332655d8c
MD5 e76cdf65ecc95adf9e8d46bbf41972a1
BLAKE2b-256 949fef893f8464412baf811f7810ba6d8ba3658b5eec58d35bbb7b1b0b742d5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for taskiq_deduplication-1.0.1-py3-none-any.whl:

Publisher: build-release.yml on d3vyce/taskiq-deduplication

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page