Pub sub implementation
Project description
Event Channel
Another library with a pub/sub implementation. You can subscribe functions to a certain topic (aka event). When a message is sent through this event callback functions subscribed will be executed.
from event_channel import EventChannel
mychannel = EventChannel() # You can also import channel, is an instance already created
def callback(x):
x = x + 1
print(x)
mychannel.subscribe("myevent", callback)
mychannel.publish("myevent", 345)
channel.unsubscribe("myevent", callback)
from event_channel.threaded_event_channel import ThreadedEventChannel
mychannel = ThreadedEventChannel(blocking=False) # You can also import non_blocking_channel, is an instance already created
def callback(x):
x = x + 1
print(x)
mychannel.subscribe("myevent", callback)
mychannel.subscribe("myevent", callback2)
threads = mychannel.publish("myevent", 345)
# Wait thread finish
for thread in threads:
thread.join()
from event_channel.threaded_event_channel import ThreadedEventChannel
my_blocking_channel = ThreadedEventChannel() # You can also import channel, is an instance already created
def callback(x):
x = x + 1
print(x)
mychannel.subscribe("myevent", callback)
mychannel.subscribe("myevent", callback2)
threads = mychannel.publish("myevent", 345)
#at this point all threads are finished
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
event_channel-0.4.3.tar.gz
(14.9 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 event_channel-0.4.3.tar.gz.
File metadata
- Download URL: event_channel-0.4.3.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9e121ec670a31e2595b3c1274f4a1c51540ade4e362120b8418a0aba0290c3c
|
|
| MD5 |
3b2451f830bec7a353550fe4a6f5ce96
|
|
| BLAKE2b-256 |
26f9afa1e794a0cd5f2ed6d742104fd89bc999f15980b5ec836910144d5368e4
|
File details
Details for the file event_channel-0.4.3-py3-none-any.whl.
File metadata
- Download URL: event_channel-0.4.3-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b52381b9affc02e83ce4cd2a16096b747df8ce1c7a84a62bd9f23a959d51d0d
|
|
| MD5 |
e5e682226ffe90eecc352523f29cfc09
|
|
| BLAKE2b-256 |
d11b25a18971f457072cfc3b519ad0a635132b55638e7a193ae2a8de96407ae8
|