Skip to content

Commit

Permalink
Simplify error handling in WebSocketServerProtocol.handler().
Browse files Browse the repository at this point in the history
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%.
  • Loading branch information
cjerdonek committed Jul 22, 2017
1 parent e83b826 commit b5b6ead
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions websockets/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit b5b6ead

Please sign in to comment.