Skip to content

Commit 3f9d333

Browse files
committed
Workaround for multiple waitFor where await must be used.
Bump version to 2.0.7.
1 parent 2ca3690 commit 3f9d333

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

asyncdispatch2.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
packageName = "asyncdispatch2"
2-
version = "2.0.6"
2+
version = "2.0.7"
33
author = "Status Research & Development GmbH"
44
description = "Asyncdispatch2"
55
license = "Apache License 2.0 or MIT"

asyncdispatch2/asyncloop.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ template processTimers(loop: untyped) =
227227
template processCallbacks(loop: untyped) =
228228
var count = len(loop.callbacks)
229229
for i in 0..<count:
230+
# This is mostly workaround for people which are using `waitFor` where
231+
# it must be used `await`. While using `waitFor` inside of callbacks
232+
# dispatcher's callback list is got decreased and length of
233+
# `loop.callbacks` become not equal to `count`, its why `IndexError`
234+
# can be generated.
235+
if len(loop.callbacks) == 0: break
230236
let callable = loop.callbacks.popFirst()
231237
callable.function(callable.udata)
232238

0 commit comments

Comments
 (0)