From 4e6f2b5313418c5f070611adb3b29a70c621782b Mon Sep 17 00:00:00 2001 From: Ray Imber Date: Thu, 10 Oct 2019 17:53:44 -0700 Subject: [PATCH] Fix drain to correctly take into account hasPendingOperations and the timeout value --- lib/pure/asyncdispatch.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index f540c5207..38946e82f 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -1559,8 +1559,8 @@ proc drain*(timeout = 500) = ## Waits for completion events and processes them. Raises ``ValueError`` ## if there are no pending operations. In contrast to ``poll`` this ## processes as many events as are available. - if runOnce(timeout): - while hasPendingOperations() and runOnce(0): discard + if runOnce(timeout) or hasPendingOperations(): + while hasPendingOperations() and runOnce(timeout): discard proc poll*(timeout = 500) = ## Waits for completion events and processes them. Raises ``ValueError``