Skip to main content

nyxa-queue — Jobs for Nyxa

Job dispatch for apps built with nyxa. Default is sync (in-process). Optional Redis/ARQ via QUEUE_CONNECTION=redis.

At a glance

What you need Nyxa Queue
Dispatch a job nyxa_queue.dispatch(MyJob(...))
Define a job Job subclass with async def handle
Run later dispatch(MyJob(...), delay=60) (redis only)
Skip duplicates unique=True / Job.unique / unique_id= (redis / ARQ _job_id)
Retry on failure QUEUE_MAX_TRIES + raise Retry(defer=…) from nyxa_queue
Run a worker nyxa queue work (ARQ) or nyxa queue work <job> (one-shot)
Scaffold a job nyxa make:job ReindexSearch

Install

uv add nyxa-queue
# Redis/ARQ worker:
uv add 'nyxa-queue[redis]'

Quick start (sync)

from nyxa_queue import Job, dispatch, dispatch_async

class ReindexSearch(Job):
    def __init__(self, user_id: str) -> None:
        self.user_id = user_id

    async def handle(self) -> None:
        print(f"reindex {self.user_id}")

dispatch(ReindexSearch("42"))
await dispatch_async(ReindexSearch("42"))

Job instance attributes must be JSON-serializable when using Redis.

Redis / ARQ

uv add 'nyxa-queue[redis]'
QUEUE_CONNECTION=redis
QUEUE_REDIS_URL=redis://localhost:6379/0   # or REDIS_URL=
# QUEUE_MAX_TRIES=5                        # ARQ worker retries (default 5)
  • dispatch / dispatch_async enqueue (do not run inline); return ARQ job id or None
  • Worker: uv run nyxa queue work (long-running); uv run nyxa queue work --burst
  • One-shot debug (any connection): uv run nyxa queue work reindex_search

Delay (redis only)

await dispatch_async(ReindexSearch("42"), delay=60)           # seconds
await dispatch_async(ReindexSearch("42"), delay=timedelta(minutes=5))
await dispatch_async(ReindexSearch("42"), delay_until=when)   # datetime

Sync ignores delay / delay_until and runs immediately. Do not pass both.

Uniqueness (redis only)

await dispatch_async(ReindexSearch("42"), unique=True)
await dispatch_async(ReindexSearch("42"), unique_id="reindex:42")

class ReindexSearch(Job):
    unique = True
    def unique_id(self) -> str | None:
        return f"reindex:{self.user_id}"

When a duplicate is already queued/in-flight, ARQ skips enqueue and dispatch_async returns None.

Retries

Worker uses QUEUE_MAX_TRIES (default 5). Inside handle, raise ARQ’s Retry:

from nyxa_queue import Job, Retry  # Retry requires nyxa-queue[redis]

class Flaky(Job):
    async def handle(self) -> None:
        raise Retry(defer=30)  # retry after 30s

CLI

# sync / debug — run a named job once
uv run nyxa queue work reindex_search
uv run nyxa queue work playground.jobs.reindex_search:ReindexSearch

# redis — long-running ARQ worker
QUEUE_CONNECTION=redis uv run nyxa queue work
QUEUE_CONNECTION=redis uv run nyxa queue work --burst

Release files for nyxa-queue 0.1.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 nyxa-queue 0.1.0
File Size Uploaded
nyxa_queue-0.1.0.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nyxa-queue 0.1.0
File Interpreter ABI Platform
nyxa_queue-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / nyxa_queue-0.1.0.tar.gz

Download URL nyxa_queue-0.1.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c3e1efa0b491568861ee2b78397fc1fb1efc8efafbbaf0e65641de64e7653613
BLAKE2b-256 checksum
How to use checksums
80970d292744fee93481cdcdf5a8bc15a131cf8fdbeaeefb4222f65e2729eb43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","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 / nyxa_queue-0.1.0-py3-none-any.whl

Download URL nyxa_queue-0.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77c7418a4c3f0e60452c067e2b69f3bca5799557718de1e6f6b124853b84a392
BLAKE2b-256 checksum
How to use checksums
7e5ba36b45073b901e2ed70b1b771a727f961ab75229e4abbf95480b2a2f7e65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","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

This release

0.1.0 This release

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