MCPcopy Index your code
hub / github.com/python/cpython / run_server

Method run_server

Lib/test/test_socketserver.py:113–145  ·  view source on GitHub ↗
(self, svrcls, hdlrbase, testfunc)

Source from the content-addressed store, hash-verified

111
112 @threading_helper.reap_threads
113 def run_server(self, svrcls, hdlrbase, testfunc):
114 server = self.make_server(self.pickaddr(svrcls.address_family),
115 svrcls, hdlrbase)
116 # We had the OS pick a port, so pull the real address out of
117 # the server.
118 addr = server.server_address
119 if verbose:
120 print("ADDR =", addr)
121 print("CLASS =", svrcls)
122
123 t = threading.Thread(
124 name='%s serving' % svrcls,
125 target=server.serve_forever,
126 # Short poll interval to make the test finish quickly.
127 # Time between requests is short enough that we won't wake
128 # up spuriously too many times.
129 kwargs={'poll_interval':0.01})
130 t.daemon = True # In case this function raises.
131 t.start()
132 if verbose: print("server running")
133 for i in range(3):
134 if verbose: print("test client", i)
135 testfunc(svrcls.address_family, addr)
136 if verbose: print("waiting for server")
137 server.shutdown()
138 t.join()
139 server.server_close()
140 self.assertEqual(-1, server.socket.fileno())
141 if HAVE_FORKING and isinstance(server, socketserver.ForkingMixIn):
142 # bpo-31151: Check that ForkingMixIn.server_close() waits until
143 # all children completed
144 self.assertFalse(server.active_children)
145 if verbose: print("done")
146
147 def stream_examine(self, proto, addr):
148 with socket.socket(proto, socket.SOCK_STREAM) as s:

Calls 10

make_serverMethod · 0.95
pickaddrMethod · 0.95
startMethod · 0.95
joinMethod · 0.95
testfuncFunction · 0.85
assertFalseMethod · 0.80
shutdownMethod · 0.45
server_closeMethod · 0.45
assertEqualMethod · 0.45
filenoMethod · 0.45

Tested by

no test coverage detected