3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-18 08:02:51 +01:00

Irc: try to make breaking out of autoconnect loops faster

This commit is contained in:
James Lu 2017-03-10 23:55:29 -08:00
parent 0526e96dc5
commit 9e50c5e69a

View File

@ -330,7 +330,11 @@ class Irc(utils.DeprecatedAttributesObject):
log.debug('(%s) Autoconnect delay set to %s seconds.', self.name, autoconnect) log.debug('(%s) Autoconnect delay set to %s seconds.', self.name, autoconnect)
if autoconnect is not None and autoconnect >= 1: if autoconnect is not None and autoconnect >= 1:
log.info('(%s) Going to auto-reconnect in %s seconds.', self.name, autoconnect) log.info('(%s) Going to auto-reconnect in %s seconds.', self.name, autoconnect)
time.sleep(autoconnect) # Continue when either self.aborted is set or the autoconnect time passes.
# Compared to time.sleep(), this allows us to stop connections quicker if we
# break while while for autoconnect.
self.aborted.clear()
self.aborted.wait(autoconnect)
if self not in world.networkobjects.values(): if self not in world.networkobjects.values():
log.debug('Stopping stale connect loop for old connection %r', self.name) log.debug('Stopping stale connect loop for old connection %r', self.name)