Mercurial > xib
comparison irclib.py @ 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 | ca22fdea1c17 |
comparison
equal
deleted
inserted
replaced
209:c4f058ee3f77 | 210:fb0cf6bf9eab |
---|---|
238 for s in sockets: | 238 for s in sockets: |
239 for c in self.connections: | 239 for c in self.connections: |
240 if s == c._get_socket(): | 240 if s == c._get_socket(): |
241 c.lock.acquire() | 241 c.lock.acquire() |
242 if hasattr(c, 'socket'): | 242 if hasattr(c, 'socket'): |
243 try: | 243 c.process_data() |
244 c.process_data() | |
245 except ServerNotConnectedError: | |
246 if c.real_nickname == self.bot.nickname: | |
247 self.bot.restart(message='Lost bot IRC connection') | |
248 else: | |
249 c.disconnect(volontary=True) | |
250 c.connect() | |
251 c.lock.release() | 244 c.lock.release() |
252 | 245 |
253 def process_timeout(self): | 246 def process_timeout(self): |
254 """Called when a timeout notification is due. | 247 """Called when a timeout notification is due. |
255 | 248 |
298 self.disconnect_all(message='Stopping bot') | 291 self.disconnect_all(message='Stopping bot') |
299 break | 292 break |
300 try: | 293 try: |
301 self.process_once(timeout) | 294 self.process_once(timeout) |
302 except ServerNotConnectedError: | 295 except ServerNotConnectedError: |
303 self.bot.restart() | 296 c = e.args[1] |
297 if c.real_nickname == self.bot.nickname: | |
298 self.bot.restart(message='Lost bot IRC connection') | |
299 else: | |
300 c.disconnect(volontary=True) | |
301 c.connect() | |
304 except: | 302 except: |
305 self.bot.error(say_levels.error, 'Unkonwn exception on IRC thread:\n'+traceback.format_exc(), send_to_admins=True) | 303 self.bot.error(say_levels.error, 'Unkonwn exception on IRC thread:\n'+traceback.format_exc(), send_to_admins=True) |
306 | 304 |
307 def disconnect_all(self, message="", volontary=True): | 305 def disconnect_all(self, message="", volontary=True): |
308 """Disconnects all connections.""" | 306 """Disconnects all connections.""" |