Skip to main content

Aiopg and PostgreSQL integration for taskiq

Project description

taskiq + aiopg

Python Linters

Plugin for taskiq that adds a new result backend based on PostgreSQL and aiopg.

Installation

This project can be installed using pip/poetry/uv (choose your preferred package manager):

pip install taskiq-aiopg

Usage

Let's see the example with the redis broker and PostgreSQL aiopg result backend (run as is):

# broker.py
import asyncio

import taskiq_redis

from taskiq_aiopg import AiopgResultBackend

result_backend = AiopgResultBackend(
    dsn="postgres://postgres:postgres@localhost:5432/postgres",
)

# Or you can use PubSubBroker if you need broadcasting
broker = taskiq_redis.ListQueueBroker(
    url="redis://localhost:6379",
).with_result_backend(result_backend)


@broker.task(task_name="best_task_ever")
async def best_task_ever() -> None:
    """Solve all problems in the world."""
    print("Start to solve all problems...")
    await asyncio.sleep(2.0)
    print("All problems are solved!")


async def main():
    print("Starting the application")
    await broker.startup()
    task = await best_task_ever.kiq()
    print(await task.wait_result())
    await broker.shutdown()


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

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 for task_id, you may need it if you want to have length of task_id more than 255 symbols;
  • serializer: type of TaskiqSerializer default is PickleSerializer;
  • **connect_kwargs: additional connection parameters, you can read more about it in aiopg repository.

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

taskiq_aiopg-0.2.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

taskiq_aiopg-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file taskiq_aiopg-0.2.0.tar.gz.

File metadata

  • Download URL: taskiq_aiopg-0.2.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.13

File hashes

Hashes for taskiq_aiopg-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2d09080f17a0d86a190090c574e789608624d448496a14eddf445b75a93ccbf3
MD5 77cc6601fc1ef389344fb6254f39713e
BLAKE2b-256 940c389c524f540eb0f35fe6223ffaf8ddeb4b1f2848a8a3482a192b395bb0e2

See more details on using hashes here.

File details

Details for the file taskiq_aiopg-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for taskiq_aiopg-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77a38677230ce0abf265455e4d3a7726900ac01e51edaff14a5599c1e4423c64
MD5 b1e93f812c915afe0279713fcf62ed7c
BLAKE2b-256 c64e6eeaf1b289b5aee76a2080c2f3e57b0496f69eb5c851b0eeff82f8430f25

See more details on using hashes here.

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