MCPcopy Index your code
hub / github.com/RustPython/RustPython / run_server

Method run_server

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

Source from the content-addressed store, hash-verified

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

Calls 12

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

Tested by

no test coverage detected