Skip to content

Commit 619cfd7

Browse files
cartertinneyCopilot
andcommitted
tests: await pending coroutine handlers
Receiver runner removal only guarantees coroutine handlers were scheduled on the handler loop. Wait for those invocations to complete before asserting the final call count. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a8070b5 commit 619cfd7

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎tests/unit/iothub/aio/test_async_handler_manager.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ async def test_handler_resolve_pending_items_before_handler_removal(
463463
handler,
464464
handler_checker,
465465
inbox,
466+
async_poll_until,
466467
):
467468
# Intercept inbox operations so the runner can be paused with work remaining
468469
original_get = inbox.get
@@ -519,6 +520,12 @@ def tracked_put(item):
519520
# Handler removal completes after the runner processes all pending items
520521
await asyncio.wait_for(removal_future, timeout=5)
521522

523+
# Coroutine handlers may still be completing on the handler loop
524+
await async_poll_until(
525+
lambda: handler_checker.handler_call_count >= 100,
526+
timeout=BATCH_COMPLETION_TIMEOUT,
527+
)
528+
522529
# Despite removal, handler has been called for everything that was in the inbox at the
523530
# time of the removal
524531
assert handler_checker.handler_call_count == 100

0 commit comments

Comments
 (0)