Skip to main content

Python background queues with an async twist

Project description

queueio

Python background queues with an async twist

Use async functions to manage complex background task workflows, and keep using synchronous functions for everything else.

Getting Started

Install queueio:

pip install queueio

Create your routines:

# basic.py
from time import sleep

from queueio import gather
from queueio import pause
from queueio import routine


@routine(name="blocking", queue="queueio")
def blocking():
    sleep(0.1)  # Regular blocking call


@routine(name="yielding", queue="queueio")
async def yielding(iterations: int):
    # Do them two at a time
    for _ in range(iterations // 2):
        await gather(blocking(), blocking())
        await pause(0.2)  # Release processing capacity
    if iterations % 2 == 1:
        await blocking()

Add the configuration to your pyproject.toml:

[tool.queueio]
# Configure RabbitMQ
pika = "amqp://guest:guest@localhost:5672/"
# Register the modules that the worker should load to find your routines
register = ["basic"]

The pika configuration can be overridden with an environment variable to allow a project to be deployed in multiple environments.

QUEUEIO_PIKA='amqp://guest:guest@localhost:5672/'

Sync the queues to the broker:

queueio sync

Submit the routine to run on a worker:

from queueio import activate
from basic import yielding

with activate():
    yielding(7).submit()

Then run the worker to process submitted routines:

queueio run queueio=4

Monitor the status of active routine invocations:

queueio monitor

Stability

The design of the public API is under active development and is likely to change with any release. Release notes will provide upgrade instructions, but backward compatibility and deprecation warnings will not generally be implemented.

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

queueio-0.2.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

queueio-0.2.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file queueio-0.2.1.tar.gz.

File metadata

  • Download URL: queueio-0.2.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for queueio-0.2.1.tar.gz
Algorithm Hash digest
SHA256 44baf50322f004051be2e983ba4c1188258cbb825409f519f01f7ac5950997f8
MD5 3fe568119558d257bd56945775cfb905
BLAKE2b-256 a2355d73c14d399a4eed4170a3d36384d0d28e9a3dae7b42f7a41f9bee20bf04

See more details on using hashes here.

Provenance

The following attestation bundles were made for queueio-0.2.1.tar.gz:

Publisher: publish.yml on ryanhiebert/queueio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file queueio-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: queueio-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for queueio-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a5b7b11890823e54f8553a8e68d1a0a8f0438864029ea4a1034c34f05c87f50
MD5 0038b9c8daf5457b41bd342358ef6a5d
BLAKE2b-256 d2427a356f78a7c31fc2f722d42fe70e195bbb75e6b5d51f0c8ee9295a7485fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for queueio-0.2.1-py3-none-any.whl:

Publisher: publish.yml on ryanhiebert/queueio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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