From b5b6eadf814f188e6aa837ec15d4f3ae424a3905 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Fri, 21 Jul 2017 19:40:06 -0700 Subject: [PATCH] Simplify error handling in WebSocketServerProtocol.handler(). Catching ConnectionError here doesn't add anything since the error will already be logged as a warning in the "else" block of the containing "except" clause: logger.warning("Error in opening handshake", exc_info=True) This commit also brings coverage back up to 100%. --- websockets/server.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/websockets/server.py b/websockets/server.py index aab6ebb5..26939f9f 100644 --- a/websockets/server.py +++ b/websockets/server.py @@ -72,14 +72,9 @@ def handler(self): # Then the response was already written. return - try: - yield from self.handshake( - response_headers, subprotocols=self.subprotocols, - extra_headers=self.extra_headers) - except ConnectionError as exc: - logger.debug( - "Connection error in opening handshake", exc_info=True) - raise + yield from self.handshake( + response_headers, subprotocols=self.subprotocols, + extra_headers=self.extra_headers) except Exception as exc: if self._is_server_shutting_down(exc): response = ('HTTP/1.1 503 Service Unavailable\r\n\r\n'