-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplest_process.py
43 lines (30 loc) · 1 KB
/
simplest_process.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
""" Simple multi-process xmlrpc server
No SSL (yet)
"""
import SocketServer
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
import fib
#functions going to be exposed
def fib_func(n):
return fib.fib(n)
def fib_server(address = None):
""" Start a xmlrpc server
"""
class SimpleThreadXMLRPCServer(SocketServer.ForkingMixIn, SimpleXMLRPCServer):
pass
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/TestSvc')
if address is None:
address = ("localhost", 8000)
server = SimpleThreadXMLRPCServer(address,
requestHandler=RequestHandler,
logRequests=True,
allow_none=True, )
print "Listening at %s/%d..." % (address[0], address[1])
server.register_function(fib_func, "fib")
server.serve_forever()
fib_server()
### To use client side:
# import xmlrpclib
# proxy = xmlrpclib.ServerProxy("http://localhost:8000/TestSvc")
# proxy.fib(5)