changeset 210:fb0cf6bf9eab

(irclib) moved ServerNotConnectedError handling from IRC.process_data() to IRC.process_forever() in order to always catch it Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 06 Mar 2010 15:57:41 +0100
parents c4f058ee3f77
children 3fe9fed07b64
files irclib.py
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/irclib.py
+++ b/irclib.py
@@ -240,14 +240,7 @@ class IRC:
                 if s == c._get_socket():
                     c.lock.acquire()
                     if hasattr(c, 'socket'):
-                        try:
-                            c.process_data()
-                        except ServerNotConnectedError:
-                            if c.real_nickname == self.bot.nickname:
-                                self.bot.restart(message='Lost bot IRC connection')
-                            else:
-                                c.disconnect(volontary=True)
-                                c.connect()
+                        c.process_data()
                     c.lock.release()
 
     def process_timeout(self):
@@ -300,7 +293,12 @@ class IRC:
             try:
                 self.process_once(timeout)
             except ServerNotConnectedError:
-                self.bot.restart()
+                c = e.args[1]
+                if c.real_nickname == self.bot.nickname:
+                    self.bot.restart(message='Lost bot IRC connection')
+                else:
+                    c.disconnect(volontary=True)
+                    c.connect()
             except:
                 self.bot.error(say_levels.error, 'Unkonwn exception on IRC thread:\n'+traceback.format_exc(), send_to_admins=True)