(self, svrcls, hdlrbase, testfunc)
| 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: |
no test coverage detected