Skip to content

Commit 6c79083

Browse files
committed
New SimpleRemoteProxy.is_connected method
1 parent 53e0acd commit 6c79083

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cdlclient/remote.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ def disconnect(self) -> None:
294294
# future, it may be useful to have a disconnect method.
295295
self._cdl = None
296296

297+
def is_connected(self) -> bool:
298+
"""Return True if connected to DataLab XML-RPC server."""
299+
if self._cdl is not None:
300+
try:
301+
self.get_version()
302+
return True
303+
except ConnectionRefusedError:
304+
self._cdl = None
305+
return False
306+
297307
def get_method_list(self) -> list[str]:
298308
"""Return list of available methods."""
299309
return self._cdl.system.listMethods()

0 commit comments

Comments
 (0)