pubsub library for simple ipc
Project description
pybsub
features
- ipc
- small (< 100 sloc)
- no external dependencies (not even imports)
example
from pybsub import PubSub
ps = PubSub()
# the channel we will subscribe to
c = "test"
# the callback function that will be fired
# when a message has been published on the
# channel we subscribed to
cb = lambda msg: print(msg)
# various ways of subscribing to a channel
# note that it returns an integer
# you will want to save this if you want to
# remove the callback later on
k = ps.subscribe(c, cb)
# or
k = ps.sub(c, cb)
# or
k = ps.s(c, cb)
# various ways of publishing
ps.publish(c, "somedata")
# or
ps.pub(c, {"some": "data"})
# or
ps.p(c, b"somedata")
# various ways of unsubscribing
# we will use the integer we received from
# subscribing here again
ps.unsubscribe(c, k)
# or
ps.unsub(c, k)
# or
ps.u(c, k)
# you could also just clear all subscriptions
ps.clear()
# or you could clear all subscriptions on a channel
ps.clear_channel()
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
pybsub-0.1.tar.gz
(2.8 kB
view details)
File details
Details for the file pybsub-0.1.tar.gz
.
File metadata
- Download URL: pybsub-0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad1ea1c367a5ed79e9486dae60bb47159862233472e9012267a50a03365da51d |
|
MD5 | ac77dc0eb3c52dd133d4c2e6bf73d45d |
|
BLAKE2b-256 | 9e7a31842ae386f8ed5e7014ae01836dfb8f69f7c31e0c021e87a073bcb89e2d |