Skip to main content

A lightweight PostgreSQL-backed distributed task queue.

Project description

PostGresql Task Queue (PGTQ)

A very simple task queue system built on PostgreSQL. PGTQ was designed to solve the following use case:

  1. I have one or more 'controllers' which will enqueue many tasks to be run in a PostgreSQL database.
  2. I have one or more 'workers' which will dequeue tasks from the database and execute them.

Installation

You can install PGTQ via pip:

pip install pgtq

Usage

Here's a simple example of how to use PGTQ:

# controller.py
from pgtq import PGTQ

# Initialize the task queue
pgtq = PGTQ(dsn="postgresql://user:password@localhost/dbname")

pgtq.install() # Create necessary tables (only needed once, but it's safe to call multiple times)

# Enqueue a task
pgtq.enqueue("add_numbers", args={"a": i, "b": i * 2})
# worker.py
from pgtq import PGTQ

# Initialize the task queue
pgtq = PGTQ(dsn="postgresql://user:password@localhost/dbname")

@pgtq.task("add_numbers")
def add_numbers(a, b):
    print("Adding:", a, "+", b, "=", a + b)
    return a + b

pgtq.start_worker()

For more detailed examples, see the examples/ directory in the repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

pgtq-0.2.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

pgtq-0.2.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pgtq-0.2.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pgtq-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c7c76f1f148291ad92f970af90a59e4dccc93461ec58d83309cf72bf9dd21ad5
MD5 4205ce218b4533e4c16aad2d9d11627d
BLAKE2b-256 dcd6b5100dc837e1f4af4255bf28a4e4b66642202b11b138ba4525b46dfff384

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pgtq-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pgtq-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2da4e0e46b06c71d0320db4d75d950d544d58e63b5556352ff6e4253c37da700
MD5 a2060975542a3c74c488bba33f63397a
BLAKE2b-256 9c0cfe0abee01ab5a1ebb767c211fd1f9c926427fb387db6a978653bd7383c6f

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