A short description of your package
Project description
shoopack
💨 shoopack — 'Shoo your messages, packed and ready'
Installation
pip install git+https://github.com/4am-ciss/shoopack
# If you want to install the latest version from the repository, use:
pip install git+https://github.com/4am-ciss/shoopack -U
Usage
Basic Usage
# Publisher Example
from shoopack import create_publisher
pub = create_publisher('zmq', address='localhost', topic_name='my_topic')
pub.publish('Hello, World!')
# Subscriber Example
from shoopack import create_subscriber
sub = create_subscriber('zmq', address='localhost', topic_name='my_topic')
msg = sub.receive()
print(msg) # Outputs: Hello, World!
Advanced Usage
Pairing Publisher and Subscriber
# Pairing Publisher and Subscriber Example (tests/pairing_pubsub.py)
# This example demonstrates how to create a pairing publisher and subscriber
import shoopack
import time
def test_pairing_pubsub():
a = shoopack.create_pairing_pubsub("zmq",
target_address="localhost",
target_port=5555,
source_address="localhost",
source_port=5556,
source_timeout=500,
protocol="tcp",
topic_name="test_topic")
b = shoopack.create_pairing_pubsub("zmq",
target_address="localhost",
target_port=5556,
source_address="localhost",
source_port=5555,
source_timeout=500,
protocol="tcp",
topic_name="test_topic")
a.listen()
b.listen()
i = 0
# await a, b is listened
while not (a._listen_loop and b._listen_loop):
print("Waiting for both A and B to start listening...")
time.sleep(0.1)
try:
while True:
a.publish({"message": f"Hello from A {i}"})
b.publish({"message": f"Hello from B {i}"})
i += 1
print(f"A gets: {a.get()}")
print(f"B gets: {b.get()}")
time.sleep(1)
except KeyboardInterrupt:
print("Test interrupted by user.")
finally:
a.close()
b.close()
print("Pairing Pub/Sub test completed and resources cleaned up.")
if __name__ == "__main__":
test_pairing_pubsub()
It will create a pairing publisher and subscriber that can communicate with each other.
The publisher sends messages, and the subscriber receives them.
It looks like this image:
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
shoopack-0.0.0a1.tar.gz
(10.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shoopack-0.0.0a1.tar.gz.
File metadata
- Download URL: shoopack-0.0.0a1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2d15c743ff044c4174fe848b751f6259e70ce859d22aafccde4d75948b7c46f
|
|
| MD5 |
d51ad9f0d1c4b7ac71d5f2aba975cf7f
|
|
| BLAKE2b-256 |
f2cdd3fb6e5189991c52af69762b2694b4e4578a6635507ae3b05a79c45950bd
|
File details
Details for the file shoopack-0.0.0a1-py3-none-any.whl.
File metadata
- Download URL: shoopack-0.0.0a1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6dbcffee83020297bed03b7abd436a7ba8ffd613c02afc02fe6d1d332f0dba6
|
|
| MD5 |
f59be076c399797fdf73483819b1ece7
|
|
| BLAKE2b-256 |
72b45781490b21ed99631619c4978954af4778438b7f9eaa619621286fd462b6
|