3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 20:22:45 +01:00

classes: ignore errors on duplicate selector.unregister()

This should really be fixed more thoroughly: there are still some remaining issues after the port to select, with disconnect / reconnect being triggered twice.
This commit is contained in:
James Lu 2018-03-29 14:04:58 -07:00
parent 29cda543e4
commit 335fb352ec

View File

@ -1612,7 +1612,10 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
self._pre_disconnect()
if self._socket is not None:
selectdriver.unregister(self)
try:
selectdriver.unregister(self)
except KeyError:
pass
try:
log.debug('(%s) disconnect: Shutting down socket.', self.name)
self._socket.shutdown(socket.SHUT_RDWR)
@ -1636,6 +1639,10 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
self._ping_timer.cancel()
self._buffer = b''
self._post_disconnect()
# Clear old sockets.
self._socket = None
self._start_reconnect()
def _start_reconnect(self):