當前位置: 首頁>>代碼示例>>Python>>正文


Python DocXMLRPCServer.handle_request方法代碼示例

本文整理匯總了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()
開發者ID:Cinnz,項目名稱:python,代碼行數:46,代碼來源:test_docxmlrpc.py

示例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()                                            #
    ########################################################################
開發者ID:carriercomm,項目名稱:Bot-18,代碼行數:32,代碼來源:DevBot.py


注:本文中的DocXMLRPCServer.DocXMLRPCServer.handle_request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。