Conversation
In test_shutdown_allows_1_export_to_finish, processor.shutdown() interrupts the in-progress export via exporter.shutdown(). Depending on thread scheduling, particularly on Windows and PyPy runners, the worker thread can terminate before shutdown() returns, causing the intermediate assertion assert worker_thread.is_alive() is True to fail intermittently. Fix this by: - Using time.monotonic() instead of time.time() for elapsed time. - Removing the unstable intermediate is_alive() is True check. - Waiting deterministically with worker_thread.join(timeout=1) before asserting that the worker thread has terminated. Fixes open-telemetry#5663 Assisted-by: Gemini 3.8 Flash
|
|
Pull request dashboard statusMerged · refreshed 2026-09-21 15:23 UTC Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused test-only changes correctly address the reported scheduling race without altering production behavior.
Review effort: Balanced
Findings: None
What changed in this PR
Improves reliability of the SDK BatchProcessor shutdown test.
Changes:
- Uses monotonic elapsed-time measurement.
- Removes a race-prone intermediate assertion.
- Replaces fixed sleep with a bounded worker-thread join.
| File | Description |
|---|---|
opentelemetry-sdk/tests/shared_internal/test_batch_processor.py |
Makes shutdown verification resilient to thread scheduling differences. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
herin049
approved these changes
Sep 21, 2026
lzchen
approved these changes
Sep 21, 2026
Merged
via the queue into
open-telemetry:main
with commit Sep 21, 2026
b1f499b
575 of 576 checks passed
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.
Description
Fixes #5663.
In
test_shutdown_allows_1_export_to_finish(opentelemetry-sdk/tests/shared_internal/test_batch_processor.py),processor.shutdown()interrupts the in-progress export viaexporter.shutdown(). Depending on thread scheduling, especially on Windows and PyPy runners, the worker thread can terminate beforeshutdown()returns. This caused the intermediate assertionassert processor._batch_processor._worker_thread.is_alive() is Trueto fail intermittently in CI.Changes
time.time()withtime.monotonic()for elapsed time measurement.is_alive() is Trueassertion immediately followingshutdown().processor._batch_processor._worker_thread.join(timeout=1)before asserting eventual termination (is_alive() is False), rather than relying on an arbitrarytime.sleep(0.1).after - before < 3.3,exporter.sleep_interrupted is True, and2 == exporter.num_export_calls) intact.Type of change
Checklist
pytest opentelemetry-sdk/tests/shared_internal/test_batch_processor.py)ruff check,ruff format --check)