API Reference¶
You can import them directly from taskiq_deduplication:
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 ( |
|
default_deduplication |
Whether deduplication is enabled by default. |
|
default_ttl |
Default lock TTL in seconds. |
|
key_prefix |
Prefix for all Redis lock keys. |
|
heartbeat |
Whether to periodically re-extend the lock TTL during task execution so long-running tasks keep their lock. |
|
heartbeat_interval |
Seconds between heartbeat refreshes. When |
|
fail_open |
Whether a Redis error while acquiring the lock lets the task
through instead of aborting the send. Detected duplicates still raise
|
taskiq_deduplication.DuplicateTaskError
¶
Bases: Exception
Raised when a task with identical name and kwargs is already queued or running.
Attributes:
| Name | Type | Description |
|---|---|---|
task_name |
Name of the task that was rejected. |
|
key |
Redis lock key whose owner caused the rejection. |
|
holder_task_id |
|