Skip to content

Commit e5f5b7f

Browse files
committed
Update README.md
1 parent e3c3fce commit e5f5b7f

1 file changed

Lines changed: 58 additions & 39 deletions

File tree

pyactive_project/README.md

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ using the standard threading library. We validated the performance and expressi
5555
* **serve_forever**. It’s used like launch function but once the function ends, the program continues.
5656

5757

58-
## How to use PyActive?
58+
## What do you need to run PyActive?
5959

6060

6161
In this section we explain all you need to use this middleware. It's easy!
6262

63+
Into Pyactive_Project folder you can find how to install the middleware in INSTALL.txt.
64+
6365
**Requirements**
6466
* If you only use the threads module, you only need Python 2.7
6567

@@ -82,42 +84,59 @@ Choose the module using the function: 'start_controller'. Nowadays,
8284
you can put either the parameter 'tasklet' or 'atom_thread' to choose the module.
8385
Note that you choose the tasklet module, you need the Stacklees Python.
8486

87+
## Hello_world example
88+
89+
In this section you can see a simple Hello World synchronous and asynchronous. In Pyactive_Project you can find more complex examples into Examples folder.
90+
91+
**Hello_World Synchronous**
92+
93+
from pyactive.controller import init_host, launch,start_controller, sleep
94+
class Server():
95+
_sync = {'hello_world':'1'}
96+
_async = []
97+
_parallel = []
98+
_ref = []
99+
def hello_world(self):
100+
return 'hello world'
101+
102+
def test():
103+
host = init_host()
104+
105+
# parameters 1 = 'id', 'test_sync' = module name, 'Server' = class name
106+
n1 = host.spawn_id('1', 'test_sync', 'Server', [])
107+
108+
response = n1.hello_world()
109+
print response
110+
111+
if __name__ == '__main__':
112+
#you can change the parameter 'tasklet' to 'pyactive_thread' if you like thread controller.
113+
start_controller('tasklet')
114+
launch(test)
115+
116+
**Hello_World Asynchronous**
117+
118+
from pyactive.controller import init_host, launch,start_controller, sleep
119+
class Server():
120+
_sync = {}
121+
_async = ['hello_world']
122+
_parallel = []
123+
_ref = []
124+
def hello_world(self):
125+
print 'hello world'
126+
127+
def test():
128+
host = init_host()
129+
130+
# parameters 1 = 'id', 'test_async' = module name, 'Server' = class name
131+
n1 = host.spawn_id('1', 'test_async', 'Server', [])
132+
133+
n1.hello_world()
134+
135+
if __name__ == '__main__':
136+
#you can change the parameter 'tasklet' to 'pyactive_thread' if you like thread controller.
137+
start_controller('tasklet')
138+
launch(test)
139+
140+
141+
85142

86-
## Perspectives uses and future work
87-
88-
89-
* **Simulation and implementation of distributed algorithms**: Pyactive can
90-
considerably simplify the development of distributed algorithms. It is
91-
possible to simulate algorithms in a single machine before they are
92-
deployed in an experimentation testbed. We implemented Chord in the past
93-
for an event-based traditional p2p simulator (PlanetSim) and the code is
94-
complex to understand and follow. On the other hand, our implementation
95-
using Pyactive is more succinct, and quit similar to the original algorithms
96-
proposed in the Chord paper. The main reason is that Pyactive clearly separates
97-
communication code from algorithm code inside methods. We plan to use Pyactive
98-
in our distributed systems course and in our peer-to-peer and networking courses.
99-
100-
* **Web middleware**: Pyactive has a big potential to ease the development of REST
101-
and Web RPC platforms. Web asynchronous networking libraries that use green
102-
threads. We are even considering to create a novel version of Pyactive on top of
103-
one these libraries. In particular, we plan to rewrite some server code of the
104-
OpenStack Swift is based on WSGI python servers that already use green threads
105-
to improve the performance. But the current code is tangling communication,
106-
marshalling and distributed storage algorithms. Pyactive can decouple these layers
107-
and make the code performance and easy to understand ans modify
108-
109-
* **Multi-core programming**: One of the promises of message passing concurrency
110-
is the future of multi-core concurrency programming. Erlang offers truly
111-
parallelism over different cores with Symmetric Multi-Processing(SMP). They mainly
112-
added multi-threading support to the Erlang VM, so that different lightweight
113-
process schedulers can live inside their native threads. In our case, stackless
114-
also permits to have different microthreads living inside their own thread or
115-
process. But python threads do not benefit from multi-core programming due to
116-
the GIL (Global Interpreter lock). Instead of that, we could support multi-core
117-
programming using the python multiprocessing library.
118-
119-
* **Distributed continuations**: We outline an important future work with the
120-
combination of RPCs and distributed continuations in Pyactive. Stackless python
121-
permits to serialize microthreads in their current frames. It is thus feasible
122-
to create novel call abstractions supporting distributed continuations between
123-
different hosts.

0 commit comments

Comments
 (0)