Hubris is a simple library for implementing inter-process communication (IPC) between separate Python processes. It's based on named pipes created by the POSIX `mkfifo` system call.
Project description
Hubris
Hubris is a simple library for implementing inter-process communication (IPC)
between separate Python processes. It's based on named pipes created by the
POSIX mkfifo
system call.
Hubris uses the "channel" metaphor. You can send and receive data on a with simple send and receive commands. Alternatively, you can have multiple processes subscribe to the a single channel on which data is published asynchronously or at a regular interval.
Sending Data
hub = Hub()
channel = hub['example']
# send data (which is serialized internally)
channel.send({'foo': 'bar'})
hub.close()
Receiving Data
Receiving data can be done synchronously or asynchronously.
hub = Hub()
channel = hub['example']
# block until we receive the data
data = channel.receive()
# ...or immediately return a future object
future = channel.receive(wait=False)
data = future.result(timeout=1)
hub.close()
Publishing Data
Data can be published at a regular interval.
hub = Hub()
channel = hub['example']
# send data (which is serialized internally)
channel.publish({'foo': 'bar'}, interval=timedelta(seconds=1))
# ...or generate data with a callback
channel.publish(generate, interval=timedelta(seconds=1))
# ...or just send data as normally to have it published to subscribers
channel.send({'foo': 'bar'})
hub.close()
Subscribing to Channels
You can subscribe a callback to receive and respond to data published on a channel.
hub = Hub()
channel = hub['example']
# subscribe this thread to the channel, triggering
# callback upon receipt of data
channel.subscribe(lambda: subscription, data: print(data))
hub.close()
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
Built Distribution
File details
Details for the file hubris-0.0.4.tar.gz
.
File metadata
- Download URL: hubris-0.0.4.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | deed125563574d5b2953a07321f403915a0631b01eb3ed3116fe46402bf1d2b4 |
|
MD5 | c8e874f6f70b324c295374d3680f19ad |
|
BLAKE2b-256 | f495002db22003227369de87160b00d287d0993a86c44f2ee3ac8c7df94d3abc |
File details
Details for the file hubris-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: hubris-0.0.4-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3a0ae61d32700c52c3b7fb32e058edb0bc992b9d84cc5e57ced9a3accd6bdef |
|
MD5 | 2a3f139398744057ee65fc3ba95f7e60 |
|
BLAKE2b-256 | a1d8619ea9542e1119a6cdaa3a8ad91ddbf3428be5b9212574422582d749c5ad |