Skip to main content

z4j-taskiqscheduler

The native TaskIQ scheduler adapter for z4j, with dashboard management of label-source schedules. Dashboard management needs the z4j server, z4j-core, z4j-bare and this adapter from the same release, plus the producer setup below.

Compatibility

TaskIQ 0.13+; Python 3.11+.

Live Redis qualification uses TaskIQ 0.13.0 with taskiq-redis 1.2.4 and redis 8.1.0 in a separate environment from arq (which requires redis below 6); keep the two dependency sets apart.

Installation and producer setup

Install z4j-taskiqscheduler and z4j-bare from the same release wave, plus the native scheduler and broker/store dependencies used by your application. The example assumes your task code, writable application-state directory and agent credentials already exist. Use the project UUID from agent registration.

import asyncio
import os
from datetime import timedelta
from myapp.tasks import broker  # Import all task definitions first.
from taskiq.cli.scheduler.run import SchedulerLoop
from taskiq.schedule_sources import LabelScheduleSource
from taskiq.scheduler.scheduler import TaskiqScheduler
from z4j_bare import NativeScheduleControl, install_agent
from z4j_taskiqscheduler import TaskiqSchedulerAdapter

async def main():
    await broker.startup()
    source = LabelScheduleSource(broker)
    await source.startup()
    adapter = TaskiqSchedulerAdapter(
        source=source, source_loop=asyncio.get_running_loop(),
        control=NativeScheduleControl("/var/lib/myapp/taskiq-schedules.sqlite3"),
    )
    agent = install_agent(
        engines=[], schedulers=[adapter],
        brain_url=os.environ["Z4J_BRAIN_URL"], token=os.environ["Z4J_TOKEN"],
        hmac_secret=os.environ["Z4J_HMAC_SECRET"], project_id=os.environ["Z4J_PROJECT_ID"],
    )
    try:
        await SchedulerLoop(TaskiqScheduler(broker, [source])).run(
            update_interval=timedelta(seconds=1),
        )
    finally:
        agent.stop()
        await broker.shutdown()

asyncio.run(main())

Start the normal TaskIQ worker separately against the same broker. Control must wrap the actual LabelScheduleSource in the scheduler process. Custom schedule sources retain their inventory and explicit deletion extension; the durable managed write path supports the stock label source only. Without control, the label source remains read-only for definitions; manual runs require its owning event loop.

Dashboard controls

The connected producer supports inventory, create, edit, pause, resume, delete and Run now. A write is complete only after z4j accepts a snapshot confirming the native source. The dashboard uses the current connection's advertised capabilities; an unavailable producer cannot accept new edits. Repeating an operation ID does not submit it twice. A timeout or uncertain outcome requires inspection before submitting a new request.

A pause prevents future scheduling. Work already queued or running can finish. Run now submits an additional execution without resuming a paused schedule. Native scheduling keeps the upstream scheduler's timing and delivery semantics; it does not acquire z4j-scheduler's catch-up, overlap or exactly-once guarantees. Queue task history requires the corresponding engine adapter in the workers.

Code definitions and durable overrides

NativeScheduleControl stores dashboard changes in a private SQLite file in the producer's application state directory. Keep that file on a durable local volume, back it up with the application, and reuse the same path after restart. Use a separate file for each application and scheduler owner. Do not put it on an ephemeral container filesystem or a network filesystem.

Code supplies the initial definitions. Each saved change overrides the fields it submits: pause and resume submit only the enabled flag, while the dashboard edit form submits every editable field (task, schedule type, expression, timezone, queue, arguments and enabled flag), so later code changes to those fields stay hidden. Removing a code definition removes its projection; reintroducing the same source identity restores any saved override. Deletion is a durable tombstone, so restarting the application does not recreate it. Dashboard-created schedules survive with the same file. No Python files are rewritten. New schedules can invoke only tasks already registered in the host application; deploying new task code remains an application operation.

The producer reads committed controls locally and keeps scheduling during a z4j server outage. If that local state cannot be read or validated, periodic dispatch is withheld and the error is logged. Normal task processing continues. Install control before starting periodic dispatch. Keep one periodic producer per application, as required by its native scheduler. There is currently no separate dashboard action to remove an override and restore the code default.

Supported definitions and limits

  • Supports five-field cron, positive integer interval seconds and offset-aware one-shot datetimes. Native cron weekday names and fixed offsets are preserved. Each managed definition must select exactly one trigger type; combined native cron/interval/time entries are rejected before installing control.
  • Prefer explicit unique schedule_id values in code labels. Without one, a deterministic definition hash supplies identity; changing that code definition creates a new identity and its old overrides do not transfer.
  • Two identical code label entries need distinct explicit IDs.
  • The registered task's labels determine routing; a dashboard queue override is unavailable.
  • A cached schedule is rechecked before dispatch, so paused, removed or edited definitions do not run with obsolete cached settings.

Metadata

Release files for z4j-taskiqscheduler 1.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for z4j-taskiqscheduler 1.13.0
File Size Uploaded
z4j_taskiqscheduler-1.13.0.tar.gz 19.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for z4j-taskiqscheduler 1.13.0
File Interpreter ABI Platform
z4j_taskiqscheduler-1.13.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.1 kB

Release files / z4j_taskiqscheduler-1.13.0.tar.gz

Download URL z4j_taskiqscheduler-1.13.0.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
52102d700990986de49a7ff16d7db8e92764fc482c9b9c1a37f64e93aa8ee4d9
BLAKE2b-256 checksum
How to use checksums
a31054f11bc5a00ad7bae85e2248ef2ac169d4d909f5106a91ef1b2267c08e32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / z4j_taskiqscheduler-1.13.0-py3-none-any.whl

Download URL z4j_taskiqscheduler-1.13.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a73f9f24a66fe20dd9b4cdafd5bf56b1bc81c6a7a6eae8a0a32f8dacb270e7b9
BLAKE2b-256 checksum
How to use checksums
45f7745fc6a56545046162e30af377a811aa7fc4a87d3e7e332e2c9af3e6ad2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

1.13.0 This release

2 release files

1.11.0

2 release files

1.10.0

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.7

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page