本文整理汇总了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")
示例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