From 9e50c5e69a9738f3f997c8c86d4036b3da50b39a Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 10 Mar 2017 23:55:29 -0800 Subject: [PATCH] Irc: try to make breaking out of autoconnect loops faster --- classes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes.py b/classes.py index ac6b788..2126c92 100644 --- a/classes.py +++ b/classes.py @@ -330,7 +330,11 @@ class Irc(utils.DeprecatedAttributesObject): log.debug('(%s) Autoconnect delay set to %s seconds.', self.name, autoconnect) if autoconnect is not None and autoconnect >= 1: 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(): log.debug('Stopping stale connect loop for old connection %r', self.name)