🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

aiotaskqueue

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aiotaskqueue

Asynchronous task queue framework

0.11.0
PyPI
Maintainers
1

Aiotaskqueue is a type-safe and fast distributed queue alternative to celery, rq and arq.

Example Usage

import asyncio

from redis.asyncio import Redis

from aiotaskqueue import Configuration, Publisher, TaskRouter
from aiotaskqueue.broker.redis import RedisBroker, RedisBrokerConfig
from aiotaskqueue.serialization.msgspec import MsgSpecSerializer
from aiotaskqueue.serialization.pydantic import PydanticSerializer

router = TaskRouter()


@router.task(name="task-name")
async def task(a: int, b: str) -> None:
    print(a, b)


async def main() -> None:
    configuration = Configuration(
        serialization_backends=[PydanticSerializer()],
        default_serialization_backend=MsgSpecSerializer(),
    )

    redis = Redis(host="127.0.0.1")
    broker = RedisBroker(
        redis=redis,
        consumer_name="aiotaskqueue",
        broker_config=RedisBrokerConfig(xread_count=100),
    )
    publisher = Publisher(broker=broker, config=configuration)
    async with redis, broker:
        await publisher.enqueue(task(a=42, b="string"))


if __name__ == "__main__":
    asyncio.run(main())

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts