Aiorq
Introduction
Aiorq is a distributed task queue with asyncio and redis, which rewrite from arq to make improvement and include web interface.
See documentation for more details.
Requirements
- redis >= 5.0
- aioredis >= 2.0.0
Install
pip install aiorq
Quick Start
Task Definition
# demo.py
# -*- coding: utf-8 -*-
import asyncio
import os
from aiorq.connections import RedisSettings
from aiorq.cron import cron
async def say_hello(ctx, name) -> None:
await asyncio.sleep(5)
print(f"Hello {name}")
async def startup(ctx):
print("starting... done")
async def shutdown(ctx):
print("ending... done")
async def run_cron(ctx, name_):
return f"hello {name_}"
class WorkerSettings:
redis_settings = RedisSettings(
host=os.getenv("REDIS_HOST", "127.0.0.1"),
port=os.getenv("REDIS_PORT", 6379),
database=os.getenv("REDIS_DATABASE", 0),
password=os.getenv("REDIS_PASSWORD", None)
)
functions = [say_hello]
on_startup = startup
on_shutdown = shutdown
cron_jobs = [
cron(coroutine=run_cron, kwargs={"name_": "pai"}, hour={17, 12, 18}, minute=40, second=50,
keep_result_forever=True)
]
Run aiorq worker
> aiorq tasks.WorkerSettings worker
15:08:50: Starting Queue: ohuo
15:08:50: Starting Worker: ohuo@04dce85c-1798-43eb-89d8-7c6d78919feb
15:08:50: Starting Functions: say_hello, EnHeng
15:08:50: redis_version=5.0.10 mem_usage=731.12K clients_connected=2 db_keys=9
starting...
Integration in FastAPI
> aiorq tasks.WorkerSettings server
INFO: Started server process [4524]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
Dashboard
See dashboard for more details.
Thanks
License
Metadata
Release files for aiorq 1.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiorq-1.1.9.tar.gz | 53.9 kB | Without provenance | Details for aiorq-1.1.9.tar.gz |
Release files / aiorq-1.1.9.tar.gz
| Download URL | aiorq-1.1.9.tar.gz |
|---|---|
| Size | 53.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52fd22a6b146b1e92b0fb186d7d4d0ffcaaa64f1ea938fec0b2c01f11b177d83
|
|
BLAKE2b-256 checksum How to use checksums |
579b994b8de5e177161681cc2b90e0e07650c890a70da4f6be5dd6a868b9fc63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.10.1 pkginfo/1.7.1 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.3
|
Security for aiorq 1.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.