summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorRay Imber <rayimber@gmail.com>2019-10-10 17:53:44 -0700
committerRay Imber <rayimber@gmail.com>2019-10-10 17:53:44 -0700
commit4e6f2b5313418c5f070611adb3b29a70c621782b (patch)
treed09485c571479058a9091ad3367666fb40f4d4cd /lib
parentaa84d35d8668e40e99e1a94ef859941bae029a72 (diff)
downloadNim-4e6f2b5313418c5f070611adb3b29a70c621782b.tar.gz
Fix drain to correctly take into account hasPendingOperations and the timeout value
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/asyncdispatch.nim4
1 files 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``