Skip to content

API Reference

Middleware

taskiq_deduplication.RedisDeduplicationMiddleware

Bases: TaskiqMiddleware

Prevents duplicate tasks from being queued.

When a task is dispatched, a Redis lock is acquired for the duration of its execution. Any subsequent task with the same fingerprint is rejected with DuplicateTaskError while the lock is held. The lock is released automatically on completion or error.

Attributes:

Name Type Description
redis_url

Redis connection URL passed to Redis.from_url.

default_deduplication

Whether deduplication is enabled by default.

default_ttl

Default lock TTL in seconds.

key_prefix

Prefix for all Redis lock keys.

Exceptions

taskiq_deduplication.DuplicateTaskError

Bases: Exception

Raised when a task with identical name and kwargs is already queued or running.