Skip to main content

Aiopg and PostgreSQL integration for taskiq

Project description

taskiq-aiopg

Taskiq-aiopg is a plugin for taskiq that adds a new result backend based on PostgreSQL and aiopg.

Installation

To use this project you must have installed core taskiq library:

pip install taskiq

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.1.0.tar.gz (6.0 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.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for taskiq_aiopg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8652c3b1a7db971b18e5f7f10a9e1f0c415088cfa77bf7ea27ffd3973d681db3
MD5 6e00975b0a724c703ef1c0dcab70b168
BLAKE2b-256 b09d0901b5a598f914e9b88a29b32267aa7d08666ac4986f2c481f58ad135f79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for taskiq_aiopg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15e3d74663ce218f54122db158c929e9f0ff6f3f3225bd73e077c5e942db0be2
MD5 7005324ddb1db32aa3e4f4b6219eb899
BLAKE2b-256 6660073745b84b268772fd83568c9e849bac182cfccc881df33a7ca4672c2a05

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