Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use newer websockets API to check that connection is open #1215

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions juju/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import websockets
from dateutil.parser import parse
from typing_extensions import Self, TypeAlias, overload
from websockets.protocol import State

from juju import errors, jasyncio, tag, utils
from juju.client import client
Expand Down Expand Up @@ -92,7 +93,7 @@ def status(self):
and connection._receiver_task.cancelled()
)

if stopped or not connection._ws.open:
if stopped or connection._ws.state is not State.OPEN:
return self.ERROR

# everything is fine!
Expand Down Expand Up @@ -357,8 +358,7 @@ async def close(self, to_reconnect: bool = False):
tasks_need_to_be_gathered.append(self._debug_log_task)
self._debug_log_task.cancel()

if self._ws and not self._ws.closed:
await self._ws.close()
await self._ws.close()

if not to_reconnect:
try:
Expand Down
Loading