Skip to content

Commit

Permalink
Merge pull request #56 from furbrain/master
Browse files Browse the repository at this point in the history
Fix bug with timer scheduling
  • Loading branch information
joerick committed Apr 6, 2017
2 parents 96256c6 + a742e2b commit e1096ca
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tingbot/run_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run(self):
while self.running:
if len(self.timers) > 0:
try:
self._wait(self.timers[-1].next_fire_time)
self._wait(lambda: self.timers[-1].next_fire_time)
except Exception as e:
self._error(e)
continue
Expand All @@ -102,7 +102,8 @@ def run(self):
self.schedule(next_timer)
else:
try:
self._wait(time.time() + 0.1)
wait_delay = time.time() + 0.1
self._wait(lambda: wait_delay)
except Exception as e:
self._error(e)

Expand Down Expand Up @@ -131,12 +132,12 @@ def empty_call_after_queue(cls):
cls._call_after_queue.task_done()
except Queue.Empty:
break


def _wait(self, until):
self._wait_callbacks()

while time.time() < until:
while time.time() < until():
if not self._call_after_queue.empty():
self.empty_call_after_queue()
time.sleep(0.001)
Expand Down

0 comments on commit e1096ca

Please sign in to comment.