From 411ee049d557fc22e6f3959f866d59ec2dd32443 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 22 Feb 2014 17:06:32 +0100 Subject: news: timeout bug fix --- news/newsbot.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'news') diff --git a/news/newsbot.py b/news/newsbot.py index 899c5dd2..b24a86e4 100644 --- a/news/newsbot.py +++ b/news/newsbot.py @@ -175,8 +175,8 @@ class RssBot(asybot): self.sendall(entry.title + ' ' + shorturl) self.oldnews.append(entry.link) self.lastnew = datetime.now() - except: - print(self.nickname + ': rss timeout occured') + except Exception as e: + print(str(datetime.now().hour) + ':' + str(datetime.now().minute) + ' ' + self.nickname + ': ' + str(e)) sleep(self.to) def shortenurl(self, url): @@ -193,7 +193,10 @@ class RssBot(asybot): self.send_msg(target, feed.title + ' ' + self.shortenurl(feed.link)) def sendall(self, string): - self.send_msg(self.channels, string) + try: + self.send_msg(self.channels, string) + except Exception as e: + print(self.nickname + ': failed sending all to ' + str(self.channels) + ' because of ' + str(e)); def send_msg(self, target, string): if self.connected: @@ -209,9 +212,9 @@ class RssBot(asybot): else: self.reconnect() while not self.connected: - sleep(3) - print('waiting for reconnect') - self.send_msg(string) + sleep(10) + print(self.nickname + ' waiting for reconnect') + self.send_msg(target, string) def on_invite(self, prefix, command, params, rest): for chan in rest.split(): @@ -237,5 +240,12 @@ for line in lines: bot.start_rss() bots[linear[0]] = bot -th = threading.Thread(target=loop) +def thread_handler(): + while True: + try: + loop() + except Exception as e: + print('ohoh ' + e) + +th = threading.Thread(target=thread_handler) th.start() -- cgit v1.2.3 From a9a659f9b5aa46e2486c9171270d2b18e28e81f4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 22 Feb 2014 17:07:39 +0100 Subject: news: harder retry --- news/newsbot.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'news') diff --git a/news/newsbot.py b/news/newsbot.py index b24a86e4..8834851d 100644 --- a/news/newsbot.py +++ b/news/newsbot.py @@ -139,6 +139,8 @@ class RssBot(asybot): self.loop = True self.lastnew = datetime.now() self.url_shortener = url_shortener + self.retry = True + self.on_nickinuse = lambda: None def start_rss(self): self.upd_loop = threading.Thread(target=self.updateloop) -- cgit v1.2.3