Initial attempt to catch connection resets

main
Bob Mottram 2020-08-24 20:30:48 +01:00
parent 8bbedaa3c1
commit 8aebe2b53a
1 changed files with 12 additions and 1 deletions

View File

@ -8877,6 +8877,17 @@ class PubServerUnitTest(PubServer):
protocol_version = 'HTTP/1.0' protocol_version = 'HTTP/1.0'
class EpicyonServer(ThreadingHTTPServer):
def handle_error(self, request, client_address):
# surpress connection reset errors
cls, e = sys.exc_info()[:2]
print('handle_error: ' + str(cls) + ", " + str(e))
# if cls is socket.error or cls is ConnectionResetError:
# pass
# else:
return HTTPServer.handle_error(self, request, client_address)
def runPostsQueue(baseDir: str, sendThreads: [], debug: bool) -> None: def runPostsQueue(baseDir: str, sendThreads: [], debug: bool) -> None:
"""Manages the threads used to send posts """Manages the threads used to send posts
""" """
@ -8978,7 +8989,7 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool,
pubHandler = partial(PubServer) pubHandler = partial(PubServer)
try: try:
httpd = ThreadingHTTPServer(serverAddress, pubHandler) httpd = EpicyonServer(serverAddress, pubHandler)
except Exception as e: except Exception as e:
if e.errno == 98: if e.errno == 98:
print('ERROR: HTTP server address is already in use. ' + print('ERROR: HTTP server address is already in use. ' +