Reconnect to IRC on send error
If any error is encountered while sending to IRC, try to reconnect. This is an attempt to deal with this exception: 2013-10-07 23:00:00,937 ERROR gerritbot: Exception encountered in event loop Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 225, in run self._read(event) File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 216, in _read self.change_merged(channel, data) File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 194, in change_merged self.ircbot.send(channel, msg) File "/usr/local/lib/python2.7/dist-packages/gerritbot/bot.py", line 98, in send self.connection.privmsg(channel, msg) File "/usr/local/lib/python2.7/dist-packages/irc/client.py", line 933, in privmsg self.send_raw("PRIVMSG %s :%s" % (target, text)) File "/usr/local/lib/python2.7/dist-packages/irc/client.py", line 960, in send_raw sender = self.ssl.write if self.ssl else self.socket.send AttributeError: 'NoneType' object has no attribute 'send' Change-Id: I8c845626260ec7b9ee7f9e409adba4796dd367ee
This commit is contained in:
parent
14679c6f44
commit
bcb72904de
|
@ -96,8 +96,12 @@ class GerritBot(irc.bot.SingleServerIRCBot):
|
|||
|
||||
def send(self, channel, msg):
|
||||
self.log.info('Sending "%s" to %s' % (msg, channel))
|
||||
self.connection.privmsg(channel, msg)
|
||||
time.sleep(0.5)
|
||||
try:
|
||||
self.connection.privmsg(channel, msg)
|
||||
time.sleep(0.5)
|
||||
except Exception:
|
||||
self.log.exception('Exception sending message:')
|
||||
self.reconnect()
|
||||
|
||||
|
||||
class Gerrit(threading.Thread):
|
||||
|
|
Loading…
Reference in New Issue