httpserver: Don't serve_forever when documenting

1. it binds the port, which is useless while documenting
2. in some circumstances, it prevents supybot-plugin-doc from exiting
   (because the server threads are still running)
This commit is contained in:
Valentin Lorentz 2021-04-11 13:24:10 +02:00
parent 9869136289
commit fd873fa0a5

View File

@ -446,12 +446,13 @@ class RealSupyHTTPServer(HTTPServer):
class TestSupyHTTPServer(RealSupyHTTPServer): class TestSupyHTTPServer(RealSupyHTTPServer):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.callbacks = {} self.callbacks = {}
self.server_address = ("0.0.0.0", 0)
def serve_forever(self, *args, **kwargs): def serve_forever(self, *args, **kwargs):
pass pass
def shutdown(self, *args, **kwargs): def shutdown(self, *args, **kwargs):
pass pass
if world.testing: if world.testing or world.documenting:
SupyHTTPServer = TestSupyHTTPServer SupyHTTPServer = TestSupyHTTPServer
else: else:
SupyHTTPServer = RealSupyHTTPServer SupyHTTPServer = RealSupyHTTPServer