Skip to content

Commit

Permalink
Remove websocket.close()
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Mar 16, 2024
1 parent 03b491f commit 31c7fe8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 15 deletions.
6 changes: 1 addition & 5 deletions gns3server/api/routes/compute/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ async def project_ws_notifications(websocket: Union[None, WebSocket] = Depends(w
log.info(f"Client {websocket.client.host}:{websocket.client.port} has disconnected from compute WebSocket")
except WebSocketException as e:
log.warning(f"Error while sending to controller event to WebSocket client: {e}")
finally:
try:
await websocket.close()
except OSError:
pass # ignore OSError: [Errno 107] Transport endpoint is not connected


if __name__ == "__main__":

Expand Down
5 changes: 0 additions & 5 deletions gns3server/api/routes/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,6 @@ async def controller_ws_notifications(
log.info(f"Client {websocket.client.host}:{websocket.client.port} has disconnected from controller WebSocket")
except WebSocketException as e:
log.warning(f"Error while sending to controller event to WebSocket client: {e}")
finally:
try:
await websocket.close()
except OSError:
pass # ignore OSError: [Errno 107] Transport endpoint is not connected


# @Route.post(
Expand Down
4 changes: 0 additions & 4 deletions gns3server/api/routes/controller/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@ async def project_ws_notifications(
except WebSocketException as e:
log.warning(f"Error while sending to project event to WebSocket client: {e}")
finally:
try:
await websocket.close()
except OSError:
pass # ignore OSError: [Errno 107] Transport endpoint is not connected
if project.auto_close:
# To avoid trouble with client connecting disconnecting we sleep few seconds before checking
# if someone else is not connected
Expand Down
2 changes: 1 addition & 1 deletion gns3server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def signal_handler(signame, *args):
asyncio.ensure_future(Controller.instance().reload())
else:
log.info(f"Server has got signal {signame}, exiting...")
# send SIGTERM to the server PID so uvicorn can shutdown the process
# send SIGTERM to the server PID so uvicorn can shut down the process
os.kill(os.getpid(), signal.SIGTERM)
except asyncio.CancelledError:
pass
Expand Down

0 comments on commit 31c7fe8

Please sign in to comment.