Skip to main content

Simple python message queue framework is ready to serve.

Project description

mqflow

dockhardman

mqflow is a simple Python message queue framework, providing an easy-to-use and efficient method to handle tasks asynchronously.

Github: https://github.com/dockhardman/mqflow

Installation

pip install mqflow

Features

  • Easy-to-use: mqflow provides a Pythonic API that is both simple and effective for managing message queues.
  • Flexibility: It supports different types of message queues such as FIFO, priority, and circular queues.
  • Thread-Safe: mqflow uses Python's built-in queue library to ensure that your application is thread-safe.
  • Customizable: mqflow allows you to customize your producer and consumer functions, providing great flexibility to fit your needs.

Usage

Here is an example of a simple message queue pipeline in memory:

from mqflow.broker import QueueBroker
from mqflow.producer import Producer
from mqflow.consumer import Consumer
from mqflow.pipeline import SequentialMessageQueue


def work(item, queue: "QueueBroker", *args, **kwargs):
    print(f"[{item}] -> [{queue}] -> [{''.join(args)}]")


task_num = 3
mq = SequentialMessageQueue(
    producers=[Producer(target=lambda: "Task sent", max_count=task_num)],
    consumers=[Consumer(target=work, args=("Task received",), max_count=task_num)],
    broker=QueueBroker(),
)
mq.run()
# [Task sent] -> [QueueBroker(name=QueueBroker, maxsize=0)] -> [Task received]
# [Task sent] -> [QueueBroker(name=QueueBroker, maxsize=0)] -> [Task received]
# [Task sent] -> [QueueBroker(name=QueueBroker, maxsize=0)] -> [Task received]

This creates a SequentialMessageQueue with a single producer that generates "Task sent" messages, and a single consumer that prints these messages with some additional information. The max_count parameter specifies the number of tasks the producer/consumer will handle before stopping. The broker manages the communication between producers and consumers.

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

mqflow-0.4.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

mqflow-0.4.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file mqflow-0.4.0.tar.gz.

File metadata

  • Download URL: mqflow-0.4.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.16 Darwin/22.4.0

File hashes

Hashes for mqflow-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a6d77ad0763fcebb80b1bd17d383fc518a6f8a6958b1920fdafb5320a769424f
MD5 448c9f9a6f85b6dcf53478bac8861cda
BLAKE2b-256 1ae9c080309ac4baac28f2a6b36ee51d717e123341c4bbd96b6034fad89c6ca8

See more details on using hashes here.

Provenance

File details

Details for the file mqflow-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: mqflow-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.8.16 Darwin/22.4.0

File hashes

Hashes for mqflow-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d1cef7dc053d1fb1be084a45b8bd2a1c1bcd3397128e16ded91ac6a5caf6200
MD5 42fb28920ce955f121505c22276ceb1d
BLAKE2b-256 1a4b6b6945a2e2e4ce3bcde8a174e862ae9f91de19e4d98025d2e872012781ec

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page