https://github.com/notypecheck/aiotaskqueue
https://github.com/notypecheck/aiotaskqueue
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/notypecheck/aiotaskqueue
- Owner: notypecheck
- Created: 2024-10-24T21:48:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-11-17T07:45:02.000Z (7 months ago)
- Last Synced: 2026-02-04T13:26:36.312Z (4 months ago)
- Language: Python
- Homepage: https://notypecheck.github.io/aiotaskqueue
- Size: 775 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Aiotaskqueue is a type-safe and fast distributed queue alternative to celery, rq and arq.
## Example Usage
```python
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())
```