本文整理匯總了Python中DocXMLRPCServer.DocXMLRPCServer.handle_request方法的典型用法代碼示例。如果您正苦於以下問題:Python DocXMLRPCServer.handle_request方法的具體用法?Python DocXMLRPCServer.handle_request怎麽用?Python DocXMLRPCServer.handle_request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DocXMLRPCServer.DocXMLRPCServer
的用法示例。
在下文中一共展示了DocXMLRPCServer.handle_request方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: server
# 需要導入模塊: from DocXMLRPCServer import DocXMLRPCServer [as 別名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import handle_request [as 別名]
def server(evt, numrequests):
serv = DocXMLRPCServer(("localhost", 0), logRequests=False)
try:
global PORT
PORT = serv.socket.getsockname()[1]
# Add some documentation
serv.set_server_title("DocXMLRPCServer Test Documentation")
serv.set_server_name("DocXMLRPCServer Test Docs")
serv.set_server_documentation(
"""This is an XML-RPC server's documentation, but the server can be used by
POSTing to /RPC2. Try self.add, too."""
)
# Create and register classes and functions
class TestClass(object):
def test_method(self, arg):
"""Test method's docs. This method truly does very little."""
self.arg = arg
serv.register_introspection_functions()
serv.register_instance(TestClass())
def add(x, y):
"""Add two instances together. This follows PEP008, but has nothing
to do with RFC1952. Case should matter: pEp008 and rFC1952. Things
that start with http and ftp should be auto-linked, too:
http://google.com.
"""
return x + y
serv.register_function(add)
serv.register_function(lambda x, y: x - y)
while numrequests > 0:
serv.handle_request()
numrequests -= 1
except socket.timeout:
pass
finally:
serv.server_close()
PORT = None
evt.set()
示例2: msg
# 需要導入模塊: from DocXMLRPCServer import DocXMLRPCServer [as 別名]
# 或者: from DocXMLRPCServer.DocXMLRPCServer import handle_request [as 別名]
##############
# XMLRPC msg #
############################
def msg(msg): #
return bot.sendMsg(msg)#
############################
####################
# Start Bot Thread #
##################################################
thread.start_new_thread(bot.Listen,('DevBot-1',))#
##################################################
#######################
# Setup XMLRPC Server #
########################################################################
query = "SELECT address,port FROM devbot WHERE LOWER(name) = 'DevBot' \
LIMIT 1" #
svrnfo = db.query(query) #
try: #
svrnfo = svrnfo[0] #
except: #
print "No instance found!" #
sys.exit(1) #
server = DocXMLRPCServer(svrnfo, logRequests=0) #
server.set_server_name("DevBot") #
server.register_function(msg) #
while not bot.terminateFlag: #
server.handle_request() #
########################################################################