def watchdog(self):
if time.time() > int(self.parent.cfg.get('watchdog', 'maxtime', default=300))+self.lastreceived:
self.parse("ERROR :Fake-error from watchdog timer.")
- self.watchdogtimer = MyTimer(int(self.parent.cfg.get('watchdog', 'interval', default=30)), self.watchdog)
+ watchdogtimer = MyTimer(int(self.parent.cfg.get('watchdog', 'interval', default=30)), self.watchdog)
+ watchdogtimer.start()
def log(self, *args, **kwargs):
self.parent.log(self.nick, *args, **kwargs)
self._checknick()
def _goterror(self, pieces):
# TODO: better handling, just reconnect that single bot
+ self.parent.mustquit = Exception(' '.join(pieces))
try:
self.quit("Error detected: %s" % ' '.join(pieces))
except: pass
curs = self.parent.query("UPDATE bots SET connected = 0")
curs.close()
except: pass
- os._exit(2) # can't use sys.exit since we might be in a sub-thread
+ sys.exit(2)
def _got001(self, pieces):
# We wait until the end of MOTD instead to consider ourselves registered, but consider uptime as of 001
self.connecttime = time.time()
self.msg(user, "Command failed. Code: CBEXC%09.3f" % (time.time() % 100000))
self.__debug_cbexception("hook", user=user, target=target, msg=msg)
except SystemExit as e:
+ self.parent.mustquit = e
try:
curs = self.parent.query("UPDATE bots SET connected = 0")
curs.close()
def __repr__(self): return "<Channel %r>" % (self.name)
def __init__(self, cfg):
+ self.mustquit = None
self.starttime = time.time()
self.cfg = cfg
self.trigger = cfg.trigger
return chan
def poll(self):
+ timeout_seconds = 30
if self.potype == "poll":
- return [fd for (fd, ev) in self.po.poll()]
+ pollres = self.po.poll(timeout_seconds * 1000)
+ return [fd for (fd, ev) in pollres]
elif self.potype == "select":
- return select.select(self.fdlist, [], [])[0]
+ return select.select(self.fdlist, [], [], timeout_seconds)[0]
def connectall(self):
for bot in self.bots.values():
for fileno in poready:
for line in main.fd(fileno).getdata():
main.fd(fileno).parse(line)
+ if main.mustquit is not None:
+ raise main.mustquit
if __name__ == '__main__':
try: os.rename('logfile', 'oldlogs/%s' % (time.time()))