3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

IRCNetwork: run _run_autoconnect in a thread so it doesn't block whatever calls disconnect()

This commit is contained in:
James Lu 2018-03-17 15:26:36 -07:00
parent 30bcd8ca79
commit 8100a4cea6

View File

@ -1508,8 +1508,14 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
self._buffer = b'' self._buffer = b''
self._post_disconnect() self._post_disconnect()
def _reconnect():
# _run_autoconnect() will block and return True after the autoconnect
# delay has passed, if autoconnect is disabled. (We do not want it to
# block whatever is calling disconnect() though.)
if self._run_autoconnect(): if self._run_autoconnect():
self.connect() self.connect()
t = threading.Thread(target=_reconnect, name="Reconnecting network %s" % self.name)
t.start()
def handle_events(self, line): def handle_events(self, line):
raise NotImplementedError raise NotImplementedError