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

Class LoopbackHttpServerThread

Lib/test/test_urllib2_localnet.py:57–80  ·  view source on GitHub ↗

Stoppable thread that runs a loopback http server.

Source from the content-addressed store, hash-verified

55 return (request, client_address)
56
57class LoopbackHttpServerThread(threading.Thread):
58 """Stoppable thread that runs a loopback http server."""
59
60 def __init__(self, request_handler):
61 threading.Thread.__init__(self)
62 self._stop_server = False
63 self.ready = threading.Event()
64 request_handler.protocol_version = "HTTP/1.0"
65 self.httpd = LoopbackHttpServer(("127.0.0.1", 0),
66 request_handler)
67 self.port = self.httpd.server_port
68
69 def stop(self):
70 """Stops the webserver if it's currently running."""
71
72 self._stop_server = True
73
74 self.join()
75 self.httpd.server_close()
76
77 def run(self):
78 self.ready.set()
79 while not self._stop_server:
80 self.httpd.handle_request()
81
82# Authentication infrastructure
83

Callers 3

setUpMethod · 0.85
setUpMethod · 0.85
start_serverMethod · 0.85

Calls

no outgoing calls

Tested by 3

setUpMethod · 0.68
setUpMethod · 0.68
start_serverMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…