mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-12 13:12:36 +01:00
IRCNetwork: simplify connection error handling
This commit is contained in:
parent
579b5ce93f
commit
b2421f5e15
18
classes.py
18
classes.py
@ -1676,14 +1676,8 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
# Use a lower timeout for the initial connect.
|
# Use a lower timeout for the initial connect.
|
||||||
self._socket.settimeout(self.pingfreq)
|
self._socket.settimeout(self.pingfreq)
|
||||||
|
|
||||||
try:
|
# Start the actual connection
|
||||||
self._socket.connect((ip, port))
|
self._socket.connect((ip, port))
|
||||||
except (ssl.SSLError, OSError):
|
|
||||||
if world.shutting_down.is_set():
|
|
||||||
return
|
|
||||||
log.exception('Unable to connect to network %r', self.name)
|
|
||||||
self._start_reconnect()
|
|
||||||
return
|
|
||||||
|
|
||||||
if self not in world.networkobjects.values():
|
if self not in world.networkobjects.values():
|
||||||
log.debug("(%s) _connect: disconnecting socket %s as the network was removed",
|
log.debug("(%s) _connect: disconnecting socket %s as the network was removed",
|
||||||
@ -1725,12 +1719,8 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
|||||||
log.info('(%s) Server ready; listening for data.', self.name)
|
log.info('(%s) Server ready; listening for data.', self.name)
|
||||||
self.autoconnect_active_multiplier = 1 # Reset any extra autoconnect delays
|
self.autoconnect_active_multiplier = 1 # Reset any extra autoconnect delays
|
||||||
|
|
||||||
# _run_irc() or the protocol module it called raised an exception, meaning we've disconnected!
|
# _run_irc() or the protocol module it called raised an exception, meaning we've disconnected
|
||||||
# Note: socket.error, ConnectionError, IOError, etc. are included in OSError since Python 3.3,
|
except:
|
||||||
# so we don't need to explicitly catch them here.
|
|
||||||
# We also catch SystemExit here as a way to abort out connection threads properly, and stop the
|
|
||||||
# IRC connection from freezing instead.
|
|
||||||
except (OSError, RuntimeError, SystemExit) as e:
|
|
||||||
self._log_connection_error('(%s) Disconnected from IRC:', self.name, exc_info=True)
|
self._log_connection_error('(%s) Disconnected from IRC:', self.name, exc_info=True)
|
||||||
if not self._aborted.is_set():
|
if not self._aborted.is_set():
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
Loading…
Reference in New Issue
Block a user