本文整理汇总了Python中SimpleXMLRPCServer.server_close方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLRPCServer.server_close方法的具体用法?Python SimpleXMLRPCServer.server_close怎么用?Python SimpleXMLRPCServer.server_close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLRPCServer
的用法示例。
在下文中一共展示了SimpleXMLRPCServer.server_close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Network
# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import server_close [as 别名]
class Network(object):
def __init__(self, config,log):
self.log = log
xmlport = config.getValue("xmlport")
xmlhost = config.getValue("xmlhost")
udpport = config.getValue("udpport")
udphost = config.getValue("udphost")
self.xml = SimpleXMLRPCServer((xmlhost, xmlport))
self.udp = netServer(udphost,udpport,log)
log.StartupMessage("* Attempting to start XML-RPC Server")
self.udp.serve_forever()
self.xmlThread = Thread( target = self.startXMLRPCServer )
self.xmlThread.setDaemon( True )
self.xmlThread.start()
log.StartupMessage( " XML-RPC Server is up at port %d" % xmlport)
def register_function(self,func,funcname):
self.xml.register_function(func,funcname)
self.udp.register_function(func,funcname)
self.log.Notice("Registered funtion %s for network access" % funcname)
def stopServices(self):
self.udp.stopServer()
self.udp.join()
self.log.StartupMessage("* Attempting to stop XML-RPC Server")
self.xml.server_close()
#self.xmlThread.join()
def startXMLRPCServer(self):
self.xml.serve_forever()
示例2: StatusCollector
# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import server_close [as 别名]
'''
_logger.error('StatusCollector has died. Exiting program.')
# Stop the XML-RPC server to exit serve_forever
global stopping
stopping = True
serverXMLRPC.server_close()
# Instantiate the StatusCollector and start the XML-RPC server
try:
# Create our StatusCollector which talks to the Spectracom
collector = StatusCollector('timeserver', '/data/hcr/spectracom_log',
onStatusCollectorFailure)
# The main thread is devoted to just running the XML-RPC server. This
# will finish when a SIGINT is received (i.e., via ^C) or a SIGTERM
# is received (e.g., via a 'kill' command).
serverXMLRPC.serve_forever()
except socket.error as e:
# Ignore socket.error if we're stopping the server, otherwise
# complain and exit
if (not stopping):
_logger.error('Exiting on XML-RPC server socket error: %s' % (e))
serverXMLRPC.server_close()
# Perform a clean shutdown of the XML-RPC server
serverXMLRPC.shutdown()
# Unregister with procmap
procmapUnregister()
_logger.info('Finished ' + time.asctime())
示例3: Exception
# 需要导入模块: import SimpleXMLRPCServer [as 别名]
# 或者: from SimpleXMLRPCServer import server_close [as 别名]
if match is None:
raise Exception('The function called must be part of the app object')
try:
func = eval(method)
except:
raise Exception('Method %s is does not exist' % method)
#call the function if it is exposed
if func is not None:
result = func(*params)
if result[0].value.has_key('value'):
return result[0].value['value'].value
else:
raise Exception('Return type is not currently supported by Marionette Server')
if __name__ == '__main__':
server = SimpleXMLRPCServer(("localhost", 21777), requestHandler=SimpleXMLRPCRequestHandler, allow_none = True)
server.register_introspection_functions()
args = ParseArgs.ParseArgs(sys.argv)
app = NescApp.NescApp(args.buildDir, args.motecom, tosbase=False, localCommOnly=True)
myFunctions = MarionetteServer(app)
server.register_instance(myFunctions, allow_dotted_names = True)
try:
server.serve_forever()
finally:
server.server_close()