Skip to content

taskiq

Requires TaskIQ 0.11+ and <1, Python 3.10+. See the compatibility matrix for the full pin string.

Terminal window
pip install z4j-taskiq

taskiq’s extensibility is middleware-based. The framework adapters wire it automatically; for bare usage, use attach_to_broker or add the middleware manually:

from taskiq_redis import RedisAsyncResultBackend, ListQueueBroker
from z4j_taskiq import attach_to_broker
broker = ListQueueBroker("redis://localhost:6379")
broker = broker.with_result_backend(RedisAsyncResultBackend("redis://..."))
attach_to_broker(broker)

attach_to_broker adds Z4JTaskiqMiddleware and is the supported entry point.

taskiq hook z4j event
pre_send task_sent
pre_execute task_started
post_execute (no exception) task_succeeded
post_execute (exception) task_failed
retries (via retry middleware) task_retry
Verb How
retry task.kiq(*args, **kwargs) with original payload
cancel await broker.cancel_task(task_id) where backend supports it
purge_queue backend-specific; Redis: FLUSHDB-scoped

taskiq supports multiple brokers in one process. Each broker appears separately in the dashboard.

taskiq-scheduler is writable: schedules stored in Redis / Postgres / file backends can be created and modified from the UI. See scheduler: taskiq-scheduler.

  • ZeroMQBroker - in-memory distribution between processes. Works with z4j but each process is a separate agent.
  • AioPikaBroker (RabbitMQ) - queue length via RabbitMQ management API.
  • InMemoryBroker - local-only, useful for tests; z4j captures events but there’s no cross-process visibility.

Frameworks that load multiple brokers (e.g. one Redis + one RabbitMQ) call attach_to_broker on each. Each broker appears as its own engine entry in the dashboard.