Python program communication interface
Project description
app-net
Pure python peer-to-peer interfacing framework. Define functions that can be executed from within the running instance of python, just like a normal function. Or execute the same function on a remote peer running either the same application or a compatible function and return the result as though it was run locally.
Link to the Documentation.
Basic Example
Below is a basic example of defining an application that is running on 2 separate hosts independently. We will define a simple function that will take a positional argument and keyword argument then multiplies them together and returns the result.
First we will define our function
import net
@net.connect()
def my_function(some_arg, some_kwarg=5):
return some_arg * some_kwarg
Now we can launch 2 instances of python. It can be either on the same or remote host, net handles this through peer ids.
>>> import net
>>> # run this function locally on this instance of python
>>> my_function(5, some_kwarg=10)
50
>>> # get all peers on the network
>>> for peer_id in net.peers():
... # execute the same function but on other instances of python and return the results
... print(my_function(5, some_kwarg=10, peer=peer_id))
...
50
Project details
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
Hashes for app_net-0.3.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afbf251ffd8be82ae936b4791752d175d42444a706364fccd24f24d27bcf2612 |
|
MD5 | 73d301f42d28e9b1c9dae1212adef704 |
|
BLAKE2b-256 | c4d9930935cefc4bf5fb42c7cd996e49d433a93db5b7009f67802849fe9e0513 |