concise publish/subscribe utility
Project description
A concise Publish/Subscribe utility module. It supports both free-form signal names and a stricter style where signals are declared first. You can also mix them.
Usage
import smoke
class MyCls(smoke.Broker):
appears = smoke.signal('appears')
leaves = smoke.signal('leaves')
def say_hello(what):
print("hello %s" % (what,))
def say_goodbye(what):
print("good bye %s" % (what,))
# Using broker
o = MyCls()
o.subscribe("appears", say_hello)
o.publish("appears", what='world')
# Using declared signals
o = MyCls()
o.leaves.subscribe(say_goodbye)
o.leaves.publish(what='world')
# Mixing
o = MyCls()
o.subscribe("appears", say_hello)
o.appears.publish()
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
smoke-0.2.0.tar.gz
(4.6 kB
view details)
File details
Details for the file smoke-0.2.0.tar.gz
.
File metadata
- Download URL: smoke-0.2.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 590524074972eb9cbb8823c25fc7d112441d49711d8904195cb3f05e1e69bbad |
|
MD5 | 2b8f31894f689437451f6336a7663692 |
|
BLAKE2b-256 | 1c5a550f7cce4d9c7bce0c3139d164fb40fb9fdccb3ea5f8dcb80aef15b9c9d5 |