Skip to content

Make OpenHTF TestState, PhaseExecutor, and KillableThread thread-safe for concurrent phases. - #1281

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_904170357
Oct 15, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_904170357

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Make OpenHTF TestState, PhaseExecutor, and KillableThread thread-safe for concurrent phases.

  • Use thread-local storage for running_phase_state, test_api, and last_phase_record in TestState.
  • Track multiple active phases via TestState.active_phases and guard shared state access with state_lock.
  • Bind the monitor thread in core/monitors.py to the monitored phase's PhaseState so monitors keep sampling while other phases run concurrently.
  • Make TestApi.get_measurement/get_attachment (and the _strict variants) check the bound phase before consulting TestState, so lookups stay correct from threads started by a phase.
  • Raise a clearer error from TestState.test_api when called from a thread not bound to a phase while multiple phases are running.
  • Finalize test outcome as ERROR when any phase has PhaseOutcome.ERROR in finalize_normally().
  • Guard cProfile.Profile.enable() with a module lock in KillableThread so concurrent phase threads do not conflict when profiling is enabled.

@google-cla

google-cla Bot commented Apr 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@copybara-service
copybara-service Bot force-pushed the test_904170357 branch 5 times, most recently from 8aa2632 to 00e07b8 Compare April 27, 2026 23:34
@copybara-service copybara-service Bot changed the title Add PhaseGraph container to support concurrent execution Add PhaseGraph container to support concurrent execution. May 3, 2026
@copybara-service
copybara-service Bot force-pushed the test_904170357 branch 8 times, most recently from 0a2e11a to 626763b Compare May 3, 2026 13:12
@copybara-service copybara-service Bot changed the title Add PhaseGraph container to support concurrent execution. Make OpenHTF TestState, PhaseExecutor, and KillableThread thread-safe for concurrent phases. Oct 7, 2026
@copybara-service
copybara-service Bot force-pushed the test_904170357 branch 3 times, most recently from 3558936 to 0206c70 Compare October 13, 2026 23:29
… for concurrent phases.

- Use thread-local storage for running_phase_state, test_api, and last_phase_record in TestState.
- Track multiple active phases via TestState.active_phases and guard shared state access with state_lock.
- Bind the monitor thread in core/monitors.py to the monitored phase's PhaseState so monitors keep sampling while other phases run concurrently.
- Make TestApi.get_measurement/get_attachment (and the _strict variants) check the bound phase before consulting TestState, so lookups stay correct from threads started by a phase.
- Raise a clearer error from TestState.test_api when called from a thread not bound to a phase while multiple phases are running.
- Finalize test outcome as ERROR when any phase has PhaseOutcome.ERROR in finalize_normally().
- Guard cProfile.Profile.enable() with a module lock in KillableThread so concurrent phase threads do not conflict when profiling is enabled.

PiperOrigin-RevId: 1000478038
@copybara-service
copybara-service Bot merged commit 3bf3b5b into master Oct 15, 2026
19 of 20 checks passed
@copybara-service
copybara-service Bot deleted the test_904170357 branch October 15, 2026 23:46
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.

0 participants