From b5229677608ff0651d1592838a68270f6b8278b3 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 22 Mar 2018 17:42:28 -0700 Subject: [PATCH] Fix duplicate calls to _run_autoconnect --- classes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes.py b/classes.py index c501ba2..d7cb033 100644 --- a/classes.py +++ b/classes.py @@ -1301,6 +1301,7 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils): self._socket = None self._selector_key = None self._buffer = b'' + self._reconnect_thread = None def _init_vars(self, *args, **kwargs): super()._init_vars(*args, **kwargs) @@ -1471,9 +1472,6 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils): if not self._aborted.is_set(): self.disconnect() - if not self._run_autoconnect(): - return - def disconnect(self): """Handle disconnects from the remote server.""" self._pre_disconnect() @@ -1510,8 +1508,10 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils): # block whatever is calling disconnect() though.) if self._run_autoconnect(): self.connect() - t = threading.Thread(target=_reconnect, name="Reconnecting network %s" % self.name) - t.start() + + if self._reconnect_thread is None or not self._reconnect_thread.is_alive(): + self._reconnect_thread = threading.Thread(target=_reconnect, name="Reconnecting network %s" % self.name) + self._reconnect_thread.start() def handle_events(self, line): raise NotImplementedError