Skip to main content

Add your description here

Project description

LTQ

A lightweight, Async-first task queue built on Redis.

Installation

pip install ltq
# or
uv add ltq

Quick Start

import asyncio
import redis.asyncio as redis
import ltq

client = redis.from_url("redis://localhost:6379")
worker = ltq.Worker(client=client)

@worker.task()
async def send_email(to: str, subject: str, body: str) -> None:
    # your async code here
    pass

async def main():
    # Enqueue a task
    await send_email.send("user@example.com", "Hello", "World")

    # Or enqueue in bulk
    messages = [
        send_email.message("a@example.com", "Hi", "A"),
        send_email.message("b@example.com", "Hi", "B"),
    ]
    await send_email.send_bulk(messages)

asyncio.run(main())

Each task gets its own queue by default. To share a queue between tasks, pass queue_name:

@worker.task(queue_name="emails")
async def send_email(...): ...

@worker.task(queue_name="emails")
async def send_newsletter(...): ...

Running Workers

# Run a worker
ltq myapp:worker

# With options
ltq myapp:worker --concurrency 100 --log-level DEBUG

Middleware

Add middleware to handle cross-cutting concerns:

from ltq.middleware import Retry, RateLimit, Timeout

worker = ltq.Worker(
    client=client,
    middlewares=[
        Retry(max_retries=3, min_delay=1.0),
        RateLimit(requests_per_second=10),
        Timeout(timeout=30.0),
    ],
)

Built-in: Retry, RateLimit, Timeout, Sentry (requires ltq[sentry])

Custom middleware:

from ltq.middleware import Middleware, Handler
from ltq.message import Message

class Logger(Middleware):
    async def handle(self, message: Message, next_handler: Handler):
        print(f"Processing {message.task}")
        result = await next_handler(message)
        print(f"Completed {message.task}")
        return result

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ltq-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ltq-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file ltq-0.1.0.tar.gz.

File metadata

  • Download URL: ltq-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ltq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7980d0b3cb5a94fd3a99bbacd0f030cd049e464031e077d78871b1ef9f49211
MD5 b41bdf9b0ed08628347281ae0e98b21b
BLAKE2b-256 923cba89607f07816adb5e65045c9d8dc2837306ede361ced8e4095459f98873

See more details on using hashes here.

Provenance

The following attestation bundles were made for ltq-0.1.0.tar.gz:

Publisher: publish.yml on tclesius/ltq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ltq-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ltq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ltq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5c0802c0e52e04e8391544780d8521304bbcb7b9d5027f93d52faa40760e018
MD5 c53cb5969d60aedbef2a36864490fa24
BLAKE2b-256 33e602b98216b4a9878dc5a0746afd41fcc9eb84de14e6213d7e8b48f7349df9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ltq-0.1.0-py3-none-any.whl:

Publisher: publish.yml on tclesius/ltq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page