6706: Add comments about what is going on with EventClient.close()
authorPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 24 Jul 2015 18:21:58 +0000 (14:21 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Fri, 24 Jul 2015 18:22:10 +0000 (14:22 -0400)
sdk/python/arvados/events.py

index 15bcf2c0ddfe7a70c35a7d7f840ceed3acae6209..4581f05b8ad9dd9830051ff2490b25c053379c8f 100644 (file)
@@ -41,8 +41,16 @@ class EventClient(WebSocketClient):
         self.stop.set()
 
     def close(self, code=1000, reason=''):
+        # parent close() method sends a asynchronous "closed" event to the server
         super(EventClient, self).close(code, reason)
+
+        # if server doesn't respond by finishing the close handshake, we'll be
+        # stuck in limbo forever.  We don't need to wait for the server to
+        # respond to go ahead and actually close the socket.
         self.close_connection()
+
+        # wait for websocket thread to finish up (closed() is called by
+        # websocket thread in as part of terminate())
         while not self.stop.is_set():
             self.stop.wait(1)