Hello_world example

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.

Moreover, we design a turorial with a lot of examples, you can find this tutorial in examples/turorial.

Hello_World Synchronous

    from pyactive.controller import init_host, launch,start_controller, sleep
    class Server():
        _sync = {'hello_world':'1'}
        _async = []
       	_parallel = []
       	_ref = []
    
def hello_world(self): return 'hello world' def test(): host = init_host() # parameters 1 = 'id', 'test_sync' = module name, 'Server' = class name n1 = host.spawn_id('1', 'test_sync', 'Server', []) response = n1.hello_world() print response
if __name__ == '__main__': #you can change the parameter 'pyactive_thread' to 'tasklet' if you would like to run the Stackless model controller. start_controller('pyactive_thread') launch(test)

Hello_World Asynchronous

    from pyactive.controller import init_host, launch,start_controller, sleep
    
class Server(): _sync = {} _async = ['hello_world'] _parallel = [] _ref = []
def hello_world(self): print 'hello world' def test(): host = init_host() # parameters 1 = 'id', 'test_async' = module name, 'Server' = class name n1 = host.spawn_id('1', 'test_async', 'Server', []) n1.hello_world()
if __name__ == '__main__': #you can change the parameter 'pyactive_thread' to 'tasklet' if you would like to run the Stackless model controller. start_controller('pyactive_thread') launch(test)