Skip to content

tests: stabilize timeout waits - #1264

Merged
Carter Tinney (cartertinney) merged 2 commits into
mainfrom
agents/fix-timing-flake-in-sync-handler-tests
Sep 3, 2026
Merged

tests: stabilize timeout waits#1264
Carter Tinney (cartertinney) merged 2 commits into
mainfrom
agents/fix-timing-flake-in-sync-handler-tests

Conversation

@cartertinney

Copy link
Copy Markdown
Member

What changed

  • distinguish prompt polling, scheduled cross-thread/event-loop completion, and longer eventual waits
  • scale batch completion bounds by the number of queued handler effects
  • apply the timeout semantics consistently across sync and async handler-manager tests

Why

Handler callbacks are dispatched through runner threads, event loops, and thread-pool workers. Treating those effects as immediately completable with a 100 ms bound caused timing-sensitive failures under full-suite coverage load even though the expected exception handling completed.

The tests continue polling the actual observable effects; production behavior is unchanged.

Validation

  • affected sync tests: 50/50 repeated runs
  • related handler-manager and loop tests: 230 passed
  • Python 3.11 full suite with coverage: 5,454 passed
  • Ruff and Black checks passed

Use a dedicated bound for work scheduled across threads and event loops instead of treating it as promptly completable. Scale batch deadlines by item count so handler-manager tests retain effect-based polling without becoming load-sensitive.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cartertinney Carter Tinney (cartertinney) changed the title tests: stabilize handler-manager scheduling waits tests: stabilize timeout waits Sep 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused test-only changes consistently apply the documented timeout semantics without unresolved issues.

Pull request overview

Stabilizes timing-sensitive asynchronous tests without changing production behavior.

Changes:

  • Adds timeout constants for scheduled and eventual completion.
  • Scales batch waits by queued handler effects.
  • Applies consistent timeout semantics across synchronous and asynchronous tests.
File summaries
File Description
tests/unit/helpers.py Defines distinct timeout categories.
tests/unit/iothub/test_sync_handler_manager.py Stabilizes synchronous handler waits.
tests/unit/iothub/aio/test_async_handler_manager.py Stabilizes asynchronous and batch handler waits.
tests/unit/iothub/aio/test_loop_management.py Extends concurrent loop-creation waits.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cartertinney
Carter Tinney (cartertinney) merged commit bb8308c into main Sep 3, 2026
42 checks passed
@cartertinney
Carter Tinney (cartertinney) deleted the agents/fix-timing-flake-in-sync-handler-tests branch September 3, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants