Don't raise ConnectionClosed error in receiver task
authorCory Johns <johnsca@gmail.com>
Wed, 8 Mar 2017 14:39:56 +0000 (08:39 -0600)
committerCory Johns <johnsca@gmail.com>
Wed, 8 Mar 2017 14:39:56 +0000 (08:39 -0600)
juju/client/connection.py

index b9eb3bc..3ee8f16 100644 (file)
@@ -97,9 +97,11 @@ class Connection:
                     await self.messages.put(result['request-id'], result)
             except Exception as e:
                 await self.messages.put_all(e)
+                if isinstance(e, websockets.ConnectionClosed):
+                    # ConnectionClosed is not really exceptional for us,
+                    # but it may be for any pending message listeners
+                    return
                 raise
-        await self.messages.put_all(websockets.exceptions.ConnectionClosed(
-            0, 'websocket closed'))
 
     async def rpc(self, msg, encoder=None):
         self.__request_id__ += 1