Loading doc/examples/client.py +5 −5 Original line number Diff line number Diff line #!/usr/bin/env python ''' sjRpc client example. Simple sjRpc client example. ''' from __future__ import absolute_import Loading @@ -9,12 +9,10 @@ from __future__ import absolute_import import sys import random import threading import time from sjrpc.core import RpcConnection from sjrpc.utils import RpcHandler class MyClientHandler(RpcHandler): def client_random(self, min=0, max=100): Loading @@ -33,8 +31,10 @@ port = int(sys.argv[2]) conn = RpcConnection.from_addr(address, port, handler=MyClientHandler()) # Run the connection mainloop in another thread: threading.Thread(target=conn.run).start() time.sleep(0.1) t = threading.Thread(target=conn.run) t.daemon = True t.start() print 'Random = %s' % (conn.call('proxy', 'client_random'), ) conn.shutdown() doc/examples/server.py +5 −7 Original line number Diff line number Diff line #!/usr/bin/env python ''' Server mode using Gevent. Simple sjRpc server. ''' from __future__ import absolute_import import sys import random from sjrpc.server import GreenRpcServer from sjrpc.server import RpcServer from sjrpc.utils import RpcHandler, pass_connection Loading @@ -22,7 +22,7 @@ class MyHandler(RpcHandler): ''' Example of bidirectionnal RPC. When the peer call this method, the server forward the call of the specified method the peer, and return returned value. the value returned by the peer. ''' return conn.call(method, *args, **kwargs) Loading @@ -34,9 +34,7 @@ address = sys.argv[1] port = int(sys.argv[2]) # Create the server instance: rpcserver = GreenRpcServer(address, port, conn_kw=dict(handler=MyHandler())) # conn_kw (and conn_args) are arguments which are automatically passed on # client RpcConnection instances. rpcserver = RpcServer.from_addr(address, port, conn_kw=dict(handler=MyHandler())) rpcserver.loop.debug = True rpcserver.run() Loading
doc/examples/client.py +5 −5 Original line number Diff line number Diff line #!/usr/bin/env python ''' sjRpc client example. Simple sjRpc client example. ''' from __future__ import absolute_import Loading @@ -9,12 +9,10 @@ from __future__ import absolute_import import sys import random import threading import time from sjrpc.core import RpcConnection from sjrpc.utils import RpcHandler class MyClientHandler(RpcHandler): def client_random(self, min=0, max=100): Loading @@ -33,8 +31,10 @@ port = int(sys.argv[2]) conn = RpcConnection.from_addr(address, port, handler=MyClientHandler()) # Run the connection mainloop in another thread: threading.Thread(target=conn.run).start() time.sleep(0.1) t = threading.Thread(target=conn.run) t.daemon = True t.start() print 'Random = %s' % (conn.call('proxy', 'client_random'), ) conn.shutdown()
doc/examples/server.py +5 −7 Original line number Diff line number Diff line #!/usr/bin/env python ''' Server mode using Gevent. Simple sjRpc server. ''' from __future__ import absolute_import import sys import random from sjrpc.server import GreenRpcServer from sjrpc.server import RpcServer from sjrpc.utils import RpcHandler, pass_connection Loading @@ -22,7 +22,7 @@ class MyHandler(RpcHandler): ''' Example of bidirectionnal RPC. When the peer call this method, the server forward the call of the specified method the peer, and return returned value. the value returned by the peer. ''' return conn.call(method, *args, **kwargs) Loading @@ -34,9 +34,7 @@ address = sys.argv[1] port = int(sys.argv[2]) # Create the server instance: rpcserver = GreenRpcServer(address, port, conn_kw=dict(handler=MyHandler())) # conn_kw (and conn_args) are arguments which are automatically passed on # client RpcConnection instances. rpcserver = RpcServer.from_addr(address, port, conn_kw=dict(handler=MyHandler())) rpcserver.loop.debug = True rpcserver.run()