Python program communication interface
Project description
app-net
=======
![PyPI](https://img.shields.io/pypi/v/net.svg)
![PyLint](https://mperlet.github.io/pybadge/badges/8.52.svg)
![Travis](https://img.shields.io/travis/aldmbmtl/net.svg)
![Documentation Status](https://readthedocs.org/projects/net/badge/?version=latest)
![PyUp](https://pyup.io/repos/github/aldmbmtl/net/shield.svg)
![Python 3](https://pyup.io/repos/github/aldmbmtl/net/python-3-shield.svg)
![License](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)
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](https://app-net.readthedocs.io/en/latest/?).
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
```python
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.
```python
>>> 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
```
=======
![PyPI](https://img.shields.io/pypi/v/net.svg)
![PyLint](https://mperlet.github.io/pybadge/badges/8.52.svg)
![Travis](https://img.shields.io/travis/aldmbmtl/net.svg)
![Documentation Status](https://readthedocs.org/projects/net/badge/?version=latest)
![PyUp](https://pyup.io/repos/github/aldmbmtl/net/shield.svg)
![Python 3](https://pyup.io/repos/github/aldmbmtl/net/python-3-shield.svg)
![License](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)
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](https://app-net.readthedocs.io/en/latest/?).
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
```python
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.
```python
>>> 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
app-net-0.3.4.tar.gz
(20.3 kB
view hashes)
Built Distribution
Close
Hashes for app_net-0.3.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9c8e1eb54d89b787a5c44b104a63f5a9cb1a6b5bfc03f0e8166525666126f8f |
|
MD5 | ec05312c13ce7236d843c925030c7f2b |
|
BLAKE2b-256 | 483f7e7fc585463d68ab79f956945681f9e6895f0549b7c9cb05df5c086dc3e2 |