Fix drain to correctly take into account hasPendingOperations and the timeout value

This commit is contained in:
Ray Imber 2019-10-10 17:53:44 -07:00
commit 4e6f2b5313

View file

@ -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``