From fab644fd47e0bf9499d0a5d9e41b3305c63f85d8 Mon Sep 17 00:00:00 2001 From: coderkun Date: Mon, 1 Dec 2014 21:19:49 +0100 Subject: [PATCH] correctly disconnect and set retrieve connection state --- mcg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mcg.py b/mcg.py index 9e6e7d5..a39378b 100644 --- a/mcg.py +++ b/mcg.py @@ -133,7 +133,7 @@ class Client(Base): def is_connected(self): """Return the connection status.""" - return self._worker is not None + return self._worker is not None and self._worker.is_alive() def disconnect(self): @@ -264,10 +264,13 @@ class Client(Base): def _disconnect_socket(self): if self._sock_read is not None: self._sock_read.close() + self._sock_read = None if self._sock_write is not None: self._sock_write.close() + self._sock_write = None if self._sock is not None: self._sock.close() + self._sock = None self._logger.info("disconnected") self._set_connection_status(False)