TaskIQ - Asyncpg
TaskIQ-Asyncpg is a plugin for taskiq that adds a new result backend based on PostgreSQL and Asyncpg.
Installation
To use this project you must have installed core taskiq library:
pip install taskiq
This project can be installed using pip:
pip install taskiq-asyncpg
using poetry:
poetry add taskiq-asyncpg
using rye:
rye add taskiq-asyncpg
Usage
Let's see the example with the redis broker and PostgreSQL Asyncpg result backend:
# broker.py
import asyncio
from taskiq_redis import ListQueueBroker
from taskiq_asyncpg import AsyncpgResultBackend
asyncpg_result_backend = AsyncpgResultBackend(
dsn="postgres://postgres:postgres@localhost:5432/postgres",
)
# Or you can use PubSubBroker if you need broadcasting
broker = ListQueueBroker(
url="redis://localhost:6379",
result_backend=asyncpg_result_backend,
)
@broker.task
async def best_task_ever() -> None:
"""Solve all problems in the world."""
await asyncio.sleep(5.5)
print("All problems are solved!")
async def main():
await broker.startup()
task = await best_task_ever.kiq()
print(await task.wait_result())
await broker.shutdown()
if __name__ == "__main__":
asyncio.run(main())
AsyncpgResultBackend configuration
dsn: connection string to PostgreSQL.keep_results: flag to not remove results from Redis after reading.table_name: name of the table in PostgreSQL to store TaskIQ results.field_for_task_id: type of a field fortask_id, you may need it if you want to have length of task_id more than 255 symbols.serializer: type ofTaskiqAsyncpgSerializerdefault isPickleSerializer**connect_kwargs: additional connection parameters, you can read more about it in Asyncpg repository.
Metadata
Release files for taskiq-asyncpg 0.3.2
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 |
|---|---|---|---|---|
| taskiq_asyncpg-0.3.2.tar.gz | 10.3 kB | Without provenance | Details for taskiq_asyncpg-0.3.2.tar.gz |
Release files / taskiq_asyncpg-0.3.2.tar.gz
| Download URL | taskiq_asyncpg-0.3.2.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f02ba4be248ad3564804d473627365d499f073cc97062671650db2d78a5d5ae
|
|
BLAKE2b-256 checksum How to use checksums |
1d4569fa76190e28add927ef220c7e92f06188ba5123108050a32a7c6a38c956
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for taskiq-asyncpg 0.3.2
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.