Skip to main content

A publish-subscribe messaging system

Project description

SimplePubSub

SimplePubSub is a lightweight publish-subscribe messaging system implemented in Python. It provides a simple server and client for building distributed messaging applications.

Installation

You can install SimplePubSub using pip:

pip install simplepubsub

Usage

Starting the server

To start the SimplePubSub server:

from simplepubsub import PubSubServer

server = PubSubServer()
server.start()

Using the client

Here's a simple example of how to use the SimplePubSub client:

from simplepubsub import PubSubClient
import time

def on_message(topic, message):
    print(f"Received message on topic '{topic}': {message}")

# Create and connect the client
client = PubSubClient()
client.connect()

# Set up the message callback
client.on_message(on_message)

# Subscribe to a topic
client.subscribe("test_topic")

# Publish a message
client.publish("test_topic", "Hello, SimplePubSub!")

# Keep the script running
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    print("Disconnecting...")
    client.disconnect()

License

This project is licensed under the MIT License.

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

pubsubx-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

pubsubx-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pubsubx-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pubsubx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0abf1af2247c77890762b15a7ee0afe11eebbb82f716b71ef721b0afc82b37bb
MD5 5a45dde735e6eab777fb2f9dfc5bc560
BLAKE2b-256 77d4bc4974f5c517f0a57441317db3689894b4fd6340db8ae3e1b8b5dd8ab6df

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pubsubx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pubsubx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0474169c784cd1f9464fdc3535706f4c6a82e734d2591f09837136f569d48aec
MD5 3ff021df1ef9b8bdb43888c038557466
BLAKE2b-256 8997cadf3f62d4d72436c5c4633ae44f38f723439ead7151a0b48d14f927200f

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