Discard past events from reactor queue

master
Nikola Forró 6 years ago
parent 4438126fd7
commit 4b50d70dbe

@ -117,6 +117,12 @@ class ReplayBot(irc.bot.SingleServerIRCBot):
def cb(user=user, msg=msg):
return self._post_message(user, msg)
self.reactor.scheduler.execute_at(t + offset, cb)
with self.reactor.mutex:
while self.reactor.scheduler.queue:
if self.reactor.scheduler.queue[0].due():
self.reactor.scheduler.queue.pop(0)
else:
break
def _do_resync(self, tags, send_response, offset, **kwargs):
if tags['user-id'] not in self.control_users:
@ -129,6 +135,11 @@ class ReplayBot(irc.bot.SingleServerIRCBot):
ndc.delay = dc.delay + offset
ndc.target = dc.target
self.reactor.scheduler.queue[i] = ndc
while self.reactor.scheduler.queue:
if self.reactor.scheduler.queue[0].due():
self.reactor.scheduler.queue.pop(0)
else:
break
def _do_stop(self, tags, send_response, **kwargs):
if tags['user-id'] not in self.control_users:

Loading…
Cancel
Save