Skip to main content

Simple Object-based Message Queue

Project description

Simple Object-based Message Queue

Jackie Yang

Installation:

pip install somq

Usage:

import time
from enum import IntEnum
from somq import MessageQueue


class Topic(IntEnum):
    A = 1
    B = 2
    C = 3

    @staticmethod
    def all() -> ['Topic']:
        return [e.value for e in Topic]


mq = MessageQueue()
q_all = mq.subscribe([Topic.A, Topic.B, Topic.C])
q_a = mq.subscribe(Topic.A)
# publish to all
mq.publish(Topic.all(), 'all')
# publish to a
mq.publish(Topic.A, 'a')
# receive from all
print(q_all.get())
print(q_all.get())
# print 'all' and 'a'
# receive from a
print(q_a.get())
# print 'a'
# use a function to subscribe to a topic
thread = mq.subscribe_function(Topic.A, lambda x: print(x))
# publish to a
mq.publish(Topic.A, 'a')
# print 'a'
time.sleep(0.1)
# stop the thread
thread.stop()

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

somq-0.1.5.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

somq-0.1.5-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file somq-0.1.5.tar.gz.

File metadata

  • Download URL: somq-0.1.5.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for somq-0.1.5.tar.gz
Algorithm Hash digest
SHA256 80f7b59ee05f7dd43d3fb1dc6263a54dca7bb409211d2850b89a4b0a67b9473e
MD5 b1eeffebf998c5c4f3a971025652ed04
BLAKE2b-256 7ebd0e31bdd854ab5c4f9373c47857fbc5bec2c7d47313032a233a3ed4887a6b

See more details on using hashes here.

File details

Details for the file somq-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: somq-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for somq-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1ff11306192849f02c9f88a2fd4c4c49681c927efa0885a05488ce1187c6b9ef
MD5 70577218e35ec7a0cd9162f416817725
BLAKE2b-256 0deb649ed4213444a1d89d36409e173cb4722126f0289bcc7aed3efd8c5a9c3e

See more details on using hashes here.

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