Skip to main content

matrix-planner

Lightweight async task scheduler for Python 3.13+. Single dependency: croniter.

import asyncio
from matrix_planner import Planner, every

planner = Planner()


@planner.task(every("10s"))
def heartbeat() -> None:
    print("tick")


@planner.task(
    every("30s"),
    max_retries=3,
    backoff=lambda a: 2 ** a,   # 2, 4, 8… seconds between retries
    timeout="15s",               # cancel and log if execution exceeds 15s
)
async def fetch() -> None:
    ...


planner.run_forever()

Key features

Feature API
Fixed-interval schedule every("10s"), every(timedelta(minutes=5))
Cron schedule cron("*/5 * * * *")
One-shot schedule once(datetime(2026, 12, 31))
Decorator registration @planner.task(every("2s"))
Manual registration planner.add(Task(func=..., schedule=...))
Retry policy max_retries=N, backoff=float | Callable[[int], float]
Per-execution timeout timeout="15s" | timedelta | float
Error callback on_error=my_handler
Sync + async functions sync dispatched via run_in_executor
Direct task invocation task() bypasses scheduler (useful in tests)
anchor="start" first tick interval after creation, steady cadence
anchor="end" interval measured from end of each execution

Schedules

# Every 10 seconds (first tick after 10s from now)
s = every("10s")

# Every 5 minutes, anchored to end of execution
s = every("5m", anchor="end")

# Cron expression (fires at 09:00 every weekday)
s = cron("0 9 * * 1-5")

# Cron with timezone
s = cron("0 9 * * *", tz=timezone.utc)

# Fire once at a specific datetime
s = once(datetime(2026, 12, 31, 23, 59))

Task parameters

Task(
    func=my_fn,
    schedule=every("10s"),
    name="my-task",              # defaults to func.__name__
    args=(1, 2),
    kwargs={"key": "val"},
    max_retries=2,
    backoff=1.0,                 # fixed delay, or lambda a: 2 ** a
    timeout="15s",               # None = no limit
    on_error=lambda e: ...,      # called instead of logging on failure
)

Requirements

Python 3.13+. Single dependency: croniter>=6.2.3.

Install: uv add matrix-planner or pip install matrix-planner.


Written with love by dotmatrix.

Metadata

Release files for matrix-planner 0.2.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 matrix-planner 0.2.0
File Size Uploaded
matrix_planner-0.2.0.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matrix-planner 0.2.0
File Interpreter ABI Platform
matrix_planner-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / matrix_planner-0.2.0.tar.gz

Download URL matrix_planner-0.2.0.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ec478aae0096b5b04f59ea99e7d6454d5824db68a0a9537243d2d29b3b0f6afd
BLAKE2b-256 checksum
How to use checksums
856094e7ccf1186827b9542718d1dd501390420944cd57a9d71589a4fe6a1d54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / matrix_planner-0.2.0-py3-none-any.whl

Download URL matrix_planner-0.2.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4d2bda43f840dde60b6872671f233174bc76d3b60a2f6d395f5c4a5751f6447
BLAKE2b-256 checksum
How to use checksums
a9eaf9486b6dd28c77015b3db312a8daf6352034675b6feb502e483ef192badb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.2.1

2 release files

This release

0.2.0 This release

2 release files

0.1.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