本文整理匯總了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