Commits

Jeffrey Gelens committed 544798b

Fixed an infinite closing bug

  • Participants
  • Parent commits c0c6cec

Comments (0)

Files changed (1)

geventwebsocket/websocket.py

 
 MSG_SOCKET_DEAD = "Socket is dead"
 MSG_ALREADY_CLOSED = "Connection is already closed"
+MSG_CLOSED = "Connection closed"
 
 
 class WebSocket(object):
         except ProtocolError:
             self.close(1002)
         except error:
-            self.current_app.on_close(MSG_SOCKET_DEAD)
+            self.close()
+            self.current_app.on_close(MSG_CLOSED)
 
-            return None
+        return None
 
     def send_frame(self, message, opcode):
         """
         try:
             self.raw_write(header + message)
         except error:
-            raise WebSocketError("Socket is dead")
+            raise WebSocketError(MSG_SOCKET_DEAD)
 
     def send(self, message, binary=None):
         """
 
             self.environ = None
 
-            self.current_app.on_close("Connection closed")
+            self.current_app.on_close(MSG_ALREADY_CLOSED)
 
 
 class Stream(object):