3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-26 04:32:51 +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() self._pre_disconnect()
if self._socket is not None: if self._socket is not None:
selectdriver.unregister(self) try:
selectdriver.unregister(self)
except KeyError:
pass
try: try:
log.debug('(%s) disconnect: Shutting down socket.', self.name) log.debug('(%s) disconnect: Shutting down socket.', self.name)
self._socket.shutdown(socket.SHUT_RDWR) self._socket.shutdown(socket.SHUT_RDWR)
@ -1636,6 +1639,10 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
self._ping_timer.cancel() self._ping_timer.cancel()
self._buffer = b'' self._buffer = b''
self._post_disconnect() self._post_disconnect()
# Clear old sockets.
self._socket = None
self._start_reconnect() self._start_reconnect()
def _start_reconnect(self): def _start_reconnect(self):