当前位置: 首页>>代码示例>>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;未经允许,请勿转载。