Skip to content

Commit

Permalink
avoid ConnectionResetError display/with server
Browse files Browse the repository at this point in the history
  • Loading branch information
joknarf committed Dec 24, 2024
1 parent 6bb0fc3 commit 36ae170
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions pywebfs/pywebfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,9 @@ def __init__(self, title, certfiles, userp, *args, **kwargs):
# server_side=True
# )

def handle_error(self, request, client_address):
return


def log_message(*args):
"""log message"""
Expand Down Expand Up @@ -1215,12 +1218,11 @@ def daemon_d(action, pidfilepath, hostname=None, args=None):
)
with daemon_context:
log_message("Starting server")
server = init_server(hostname, args)
try:
server.serve_forever()
except KeyboardInterrupt:
log_message("Stopping server")
sys.exit(0)
with init_server(hostname, args) as server:
try:
server.serve_forever()
except KeyboardInterrupt:
log_message("Stopping server")


def init_server(hostname, args):
Expand Down Expand Up @@ -1309,13 +1311,12 @@ def main():
if args.action:
sys.exit(not daemon_d(args.action, pidfile, hostname, args))
else:
server = init_server(hostname, args)
try:
server.serve_forever()
except KeyboardInterrupt:
log_message("Stopping server")
server.socket.close()
sys.exit(0)
with init_server(hostname, args) as server:
try:
server.serve_forever()
except KeyboardInterrupt:
log_message("Stopping server")
server.socket.close()


if __name__ == "__main__":
Expand Down

0 comments on commit 36ae170

Please sign in to comment.