From 2ed08e9c89ecebdaeea8fabd657c9ea130afa835 Mon Sep 17 00:00:00 2001 From: johannesfj Date: Mon, 18 Dec 2017 17:04:18 -0800 Subject: [PATCH] Update drain_queues to check if queue has already been drained 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. --- promise/async_.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/promise/async_.py b/promise/async_.py index 5bb6bef..5180061 100644 --- a/promise/async_.py +++ b/promise/async_.py @@ -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 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: