test: exercise the production _loop_ref path in put_threadsafe tests
Gate finding (/simplify-code pass): both cross-thread tests passed loop=loop explicitly, but no production caller does — all six (_on_delta, _on_tool_*) rely on the queue resolving its own _loop_ref in __init__. The kwarg made the tests vacuous: a broken _loop_ref still passed them. Dropping the kwarg exercises the real path. Verified by mutation: with self._loop_ref = asyncio.new_event_loop() (wrong loop), both tests now FAIL; they passed before this change.
This commit is contained in:
parent
64882bc684
commit
7e344dc0dc
|
|
@ -423,7 +423,11 @@ class TestThreadSafeAsyncQueueCrossThreadBoundary:
|
|||
|
||||
def worker():
|
||||
time.sleep(0.05)
|
||||
q.put_threadsafe("from-worker", loop=loop)
|
||||
# No ``loop=`` kwarg on purpose: production callers
|
||||
# (_on_delta / _on_tool_*) never pass one, so the queue
|
||||
# must resolve its own ``_loop_ref``. Passing loop= here
|
||||
# would make a broken _loop_ref pass this test.
|
||||
q.put_threadsafe("from-worker")
|
||||
|
||||
thread = threading.Thread(target=worker, daemon=True)
|
||||
thread.start()
|
||||
|
|
@ -454,7 +458,9 @@ class TestThreadSafeAsyncQueueCrossThreadBoundary:
|
|||
|
||||
def worker(idx):
|
||||
time.sleep(0.01 + idx * 0.002)
|
||||
q.put_threadsafe(f"item-{idx}", loop=loop)
|
||||
# No ``loop=`` kwarg — exercise the production
|
||||
# ``_loop_ref`` resolution path (see the note above).
|
||||
q.put_threadsafe(f"item-{idx}")
|
||||
|
||||
threads = [
|
||||
threading.Thread(target=worker, args=(i,), daemon=True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue