Skip to content

Commit

Permalink
Update drain_queues to check if queue has already been drained
Browse files Browse the repository at this point in the history
When GeventScheduler is being used as async_.schedule there is a chance
the queues are being drained while a drain_queue job is scheduled to be
executed on the gevent event loop. This is valid so change assert is_tick_used
to check if queue has already been drained instead of throwing an assertion
exception.
  • Loading branch information
johannesfj committed Dec 19, 2017
1 parent b055d1e commit d2c4815
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions promise/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def wait(self, promise, timeout=None):
self.schedule.wait(target, timeout)

def drain_queues(self):
assert self.is_tick_used
self.drain_queue(self.normal_queue)
self.reset()
self.have_drained_queues = True
self.drain_queue(self.late_queue)
if not self.is_tick_used:
self.drain_queue(self.normal_queue)
self.reset()
self.have_drained_queues = True
self.drain_queue(self.late_queue)

def queue_tick(self):
if not self.is_tick_used:
Expand Down

0 comments on commit d2c4815

Please sign in to comment.