Repository navigation
{Test SDK} Fix foreground busy loop during playback polling - #34300
Merged
Ethan Yang (necusjz) merged 3 commits intoNov 2, 2026
Merged
Conversation
Yield to background pollers using a short threading event wait during playback while continuing to skip ARM service delays. Cover replay hook order, cleanup, playback-only registration, completion, and error propagation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the playback polling-delay change.
No open issues 🎉
What changed in this PR
This PR prevents busy looping in shared test SDK playback by giving background pollers time to progress. Production polling and live execution remain unchanged.
Changes:
- Replace the foreground playback delay with
threading.Event.wait(0.001), while keeping ARM service delays disabled. - Add regression tests for patch order, delay behavior, cleanup, playback-only registration, completion, and exception propagation.
- Document playback polling behavior.
| File | Description |
|---|---|
src/azure-cli-testsdk/README.rst |
Document playback delays and cleanup behavior. |
src/azure-cli-testsdk/azure/cli/testsdk/tests/test_patches.py |
Add regression coverage for polling delay patches. |
src/azure-cli-testsdk/azure/cli/testsdk/tests/__init__.py |
Initialize the test package. |
src/azure-cli-testsdk/azure/cli/testsdk/patches.py |
Add a short foreground wait independent of patched time.sleep. |
Review effort: Balanced
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Merged
4 tasks done
Use the same subsection heading style as HISTORY.rst so the combined package description renders without inconsistent-title errors. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Member
|
better to move the tests under |
Move existing tests without changing their contents and remove the redundant test package initializer. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Ethan Yang (necusjz)
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Validation —⚠️ Review suggested
This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.
1 added suppression
src/azure-cli-testsdk/azure/cli/testsdk/patches.pydef _yield_to_polling_thread(*args, **kwargs): # pylint: disable=unused-argumentRelated command
Shared
azure-cli-testsdkscenario playback for commands that wait for background pollers; not specific to one command module.Description
Problem:
Currently, playback replaces both ARM service polling delays and the CLI foreground completion-check delay with no-ops. However, the foreground loop can consequently spin while a background poller is trying to make progress. This caused high CPU utilization and led playback to run near as long as the live recording. (54min live, 41min playback).
Local testing showed 9.9 million polls in ~57 seconds.
Solution:
Keep the ARM service delay as a no-op, but replace the foreground playback delay with
threading.Event.wait(0.001). This requests a short real wait and yields to the background poller even when playback has patchedtime.sleepto a no-op. Existing test cleanup restores both delay methods.Local test results:
Playback down from 41min to 40sec:

Additional info:
Added regression coverage for both replay-hook orders, the no-op service delay versus the requested 1 ms foreground wait, cleanup, playback-only registration, completion, and exception propagation. Documented the behavior in the test SDK README.
This change is limited to four test SDK files. It does not change production/core polling, live execution, recordings, package versions, or Edge Action-specific behavior.
Testing Guide
Run from the repository root using the existing development environment.
AZURE_TEST_RUN_LIVEmust be unset; setting it to a nonempty string such asfalseis not equivalent.Result: passed, 21 tests and 4 subtests, with 4 warnings, in 1.82 s.
Result: passed.
Result: both passed before committing.
The local pre-commit hook reported that its Python environment was not activated and exited successfully without running its checks; the explicit pytest and flake8 commands above were run separately and passed. No live operations or full Edge Action eight-scenario playback run were performed for this publication.
History Notes
N/A. Test-only change; the
{Test SDK}title intentionally excludes a customer-facing history entry.This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.