Fix [Errno 98] Address already in use

This commit is contained in:
yo 2022-06-17 11:09:25 +02:00
parent 91f6364d95
commit 1593f8df02

View File

@ -7,6 +7,7 @@
# v.0.9 20/08/2021 First version # v.0.9 20/08/2021 First version
# v.1.0 10/05/2022 Fix for more than 1 VIP # v.1.0 10/05/2022 Fix for more than 1 VIP
# v.1.1 11/05/2022 Fix for INIT status VIP # v.1.1 11/05/2022 Fix for INIT status VIP
# v.1.2 17/06/2022 Fix "[Errno 98] Address already in use" when restarting service
# #
import http.server import http.server
@ -64,7 +65,12 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler):
else: else:
self.send_response(200) self.send_response(200)
with socketserver.TCPServer(("", PORT), RequestHandler) as httpd:
class TCPServerReuseAddr(socketserver.TCPServer):
allow_reuse_address = True
with TCPServerReuseAddr(("", PORT), RequestHandler) as httpd:
print("Serving at port", PORT) print("Serving at port", PORT)
httpd.serve_forever() httpd.serve_forever()