A generic thread class to create and run an http server.
| 565 | |
| 566 | |
| 567 | class HttpServerThread(threading.Thread): |
| 568 | """A generic thread class to create and run an http server.""" |
| 569 | |
| 570 | def __init__(self, server): |
| 571 | super().__init__() |
| 572 | self.server = server |
| 573 | |
| 574 | def stop(self): |
| 575 | """Shuts down the server if it is running.""" |
| 576 | self.server.shutdown() |
| 577 | |
| 578 | def run(self): |
| 579 | """Create a server instance and serve forever until stop() is called.""" |
| 580 | # Start the server's main loop (this blocks until shutdown() is called) |
| 581 | self.server.serve_forever() |
| 582 | |
| 583 | |
| 584 | # This will hold the ID for each worker process if running in parallel mode, |
no outgoing calls