Skip to content

Commit

Permalink
Backport fix for juju#989
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Haddon committed Mar 21, 2024
1 parent 2b8c252 commit ebf7e17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions juju/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ async def close(self, to_reconnect=False):

async def _recv(self, request_id):
if not self.is_open:
raise websockets.exceptions.ConnectionClosed(0, 'websocket closed')
raise websockets.exceptions.ConnectionClosed(
websockets.frames.Close(websockets.frames.CloseCode.NORMAL_CLOSURE,
'websocket closed'))
try:
return await self.messages.get(request_id)
except GeneratorExit:
Expand Down Expand Up @@ -615,7 +617,8 @@ async def rpc(self, msg, encoder=None):
if self.monitor.status == Monitor.DISCONNECTED:
# closed cleanly; shouldn't try to reconnect
raise websockets.exceptions.ConnectionClosed(
0, 'websocket closed')
websockets.frames.Close(websockets.frames.CloseCode.NORMAL_CLOSURE,
'websocket closed'))
try:
await self._ws.send(outgoing)
break
Expand Down

0 comments on commit ebf7e17

Please sign in to comment.