[ci skip] fix(tests): make async callback test deterministic (#5986)

Replace the fixed sleep in test_async_callbacks with a bounded wait for all expected callback results, so detached worker scheduling no longer causes sporadic CI failures.

Co-authored-by: Cursor <cursoragent@cursor.com>
diff --git a/tests/test_callbacks.py b/tests/test_callbacks.py
index c0a57a7..327e41e 100644
--- a/tests/test_callbacks.py
+++ b/tests/test_callbacks.py
@@ -179,10 +179,11 @@
     # do some work async
     work = [1, 2, 3, 4]
     m.test_async_callback(gen_f(), work)
-    # wait until work is done
-    from time import sleep
-
-    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)
+    assert len(res) == len(work), f"Timed out waiting for callbacks: res={res!r}"
     assert sum(res) == sum(x + 3 for x in work)