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


Python socketserver.ForkingMixIn方法代碼示例

本文整理匯總了Python中socketserver.ForkingMixIn方法的典型用法代碼示例。如果您正苦於以下問題:Python socketserver.ForkingMixIn方法的具體用法?Python socketserver.ForkingMixIn怎麽用?Python socketserver.ForkingMixIn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在socketserver的用法示例。


在下文中一共展示了socketserver.ForkingMixIn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_server

# 需要導入模塊: import socketserver [as 別名]
# 或者: from socketserver import ForkingMixIn [as 別名]
def run_server(self, svrcls, hdlrbase, testfunc):
        server = self.make_server(self.pickaddr(svrcls.address_family),
                                  svrcls, hdlrbase)
        # We had the OS pick a port, so pull the real address out of
        # the server.
        addr = server.server_address
        if verbose:
            print("ADDR =", addr)
            print("CLASS =", svrcls)

        t = threading.Thread(
            name='%s serving' % svrcls,
            target=server.serve_forever,
            # Short poll interval to make the test finish quickly.
            # Time between requests is short enough that we won't wake
            # up spuriously too many times.
            kwargs={'poll_interval':0.01})
        t.daemon = True  # In case this function raises.
        t.start()
        if verbose: print("server running")
        for i in range(3):
            if verbose: print("test client", i)
            testfunc(svrcls.address_family, addr)
        if verbose: print("waiting for server")
        server.shutdown()
        t.join()
        server.server_close()
        self.assertEqual(-1, server.socket.fileno())
        if HAVE_FORKING and isinstance(server, socketserver.ForkingMixIn):
            # bpo-31151: Check that ForkingMixIn.server_close() waits until
            # all children completed
            self.assertFalse(server.active_children)
        if verbose: print("done") 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:35,代碼來源:test_socketserver.py

示例2: process

# 需要導入模塊: import socketserver [as 別名]
# 或者: from socketserver import ForkingMixIn [as 別名]
def process(img_name):
    try:
        idfind = findidcard.findidcard()
        idcard_img = idfind.find(img_name)
        result_dict = idcardocr.idcardocr(idcard_img)
        result_dict['error'] = 0
    except Exception as e:
        result_dict = {'error':1}
        print(e)
    return result_dict

#SocketServer.ForkingMixIn, SocketServer.ThreadingMixIn 
開發者ID:Raymondhhh90,項目名稱:idcardocr,代碼行數:14,代碼來源:idcard_recognize.py


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