diff --git a/boswatch/network/client.py b/boswatch/network/client.py index f4fb5de..1225087 100644 --- a/boswatch/network/client.py +++ b/boswatch/network/client.py @@ -105,7 +105,12 @@ class TCPClient: @property def isConnected(self): """!Property of client connected state""" - _, write, _ = select.select([], [self._sock], [], 0.1) - if write: - return True - return False + try: + if self._sock: + read, write, _ = select.select([], [self._sock], [], 0.1) + if read and write: + return True + return False + except: + logging.exception("cannot check connection status") + return False diff --git a/test/boswatch/test_ServerClient.py b/test/boswatch/test_ServerClient.py index 6ed56b1..0c8fdcc 100644 --- a/test/boswatch/test_ServerClient.py +++ b/test/boswatch/test_ServerClient.py @@ -182,7 +182,7 @@ def test_serverStopsWhileConnected(getRunningServer, getClient): """!Shutdown server while client is connected""" getClient.connect() getRunningServer.stop() - timeout = 10 + timeout = 5 while getClient.isConnected: time.sleep(0.1) timeout = timeout - 1 @@ -221,7 +221,7 @@ def test_serverHighLoad(getRunningServer): logging.debug("start sendThreads") threads = [] for thr_id in range(10): - thr = threading.Thread(target=sendThread, name="sendThread-"+str(thr_id)) + thr = threading.Thread(target=sendThread, name="sendThread-" + str(thr_id)) thr.daemon = True thr.start() threads.append(thr)