A super-lightweight IPC (Inter-Process Communication) protocol over TCP socket.
Project description
procbridge-python
ProcBridge is a super-lightweight IPC (Inter-Process Communication) protocol over TCP socket or Unix domain socket. It enables you to send and recieve JSON between processes easily. ProcBridge is much like a simplified version of HTTP protocol, but only transfer JSON values.
Please note that this repo is the Python implementation of ProcBridge protocol. You can find detailed introduction of ProcBridge protocol in the main repository: gongzhang/procbridge.
Installation
pip install procbridge==1.2.0
Example
Server Side:
import procbridge as pb
def delegate(method, args):
# define remote methods:
if method == 'echo':
return args
elif method == 'sum':
return sum(x for x in args)
elif method == 'err':
raise RuntimeError("an server error")
if __name__ == '__main__':
PORT = 8000
s = pb.Server('0.0.0.0', PORT, delegate)
s.start(daemon=False)
print("Server is on {}...".format(PORT))
Client Side:
import procbridge as pb
client = pb.Client('127.0.0.1', 8000)
# call remote methods:
client.request("echo", 123) # 123
client.request("echo", ['a', 'b', 'c']) # ['a', 'b', 'c']
client.request("sum", [1, 2, 3, 4]) # 10
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
procbridge-1.2.0.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for procbridge-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c5ab5f6bfc5cc862b62f51dd511d498885cd85f19dca79268b1a9add04ddee1 |
|
MD5 | 0e83ad32f31b46a54b1320faf2861e53 |
|
BLAKE2b-256 | fa3d8da3d31f77b3ded2fb4342f99478df73c37709bffcba43aca1b18eec7dbf |