We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c111569 commit 1c08eb8Copy full SHA for 1c08eb8
1 file changed
tests/test_callbacks.py
@@ -179,10 +179,11 @@ def gen_f():
179
# do some work async
180
work = [1, 2, 3, 4]
181
m.test_async_callback(gen_f(), work)
182
- # wait until work is done
183
- from time import sleep
184
-
185
- sleep(0.5)
+ # Wait for all detached worker threads to finish.
+ deadline = time.monotonic() + 5.0
+ while len(res) < len(work) and time.monotonic() < deadline:
+ time.sleep(0.01)
186
+ assert len(res) == len(work), f"Timed out waiting for callbacks: res={res!r}"
187
assert sum(res) == sum(x + 3 for x in work)
188
189
0 commit comments