sandbox directory
This commit is contained in:
parent
a4f628747f
commit
37e9df38ca
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
README:
|
||||||
|
|
||||||
|
This directory is for hypothetical ideas for snippets of code,
|
||||||
|
etc that may be included into the software at some point.
|
||||||
|
|
||||||
|
setup.py will ignore this directory, and so nothing in here
|
||||||
|
will be included in tarball or package releases.
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env python2.4
|
||||||
|
|
||||||
|
import xmlrpclib
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Try and connect to current instance
|
||||||
|
proxy = xmlrpclib.ServerProxy('http://localhost:8888')
|
||||||
|
print proxy.open_file('server already exists')
|
||||||
|
except:
|
||||||
|
# if connecting failed
|
||||||
|
print "couldn't connect to socket"
|
||||||
|
import xmlrpc_simple_server
|
||||||
|
xmlrpc_simple_server.Server()
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python2.4
|
||||||
|
|
||||||
|
import SimpleXMLRPCServer
|
||||||
|
|
||||||
|
class Server:
|
||||||
|
def __init__(self):
|
||||||
|
print "Starting simple server, registering"
|
||||||
|
self.server = StoppableXMLRPCServer(('localhost',8888))
|
||||||
|
self.server.register_instance(self)
|
||||||
|
self.server.serve_forever()
|
||||||
|
|
||||||
|
def open_file(self, *args):
|
||||||
|
print "Opening files", args
|
||||||
|
return args
|
||||||
|
|
||||||
|
def shut_down(self, *args):
|
||||||
|
print "Shutting down the server"
|
||||||
|
self.server.stop = True
|
||||||
|
|
||||||
|
######
|
||||||
|
class StoppableXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
|
||||||
|
"""Override of TIME_WAIT"""
|
||||||
|
allow_reuse_address = True
|
||||||
|
|
||||||
|
def serve_forever(self):
|
||||||
|
self.stop = False
|
||||||
|
while not self.stop:
|
||||||
|
self.handle_request()
|
||||||
|
######
|
Loading…
Reference in New Issue