Skip to content

Conversation

@copybara-service
Copy link
Contributor

Fix bug in test executor where manual aborts were not letting the test clean up properly.

To understand this bug, note that:

  1. OpenHTF registers a signal handler for SIGINT
  2. This handler re-raises KeyboardInterrupt
  3. The execute function in TestDescriptor expects this, and effectively waits on the test runner thread to join - twice in the case of a manual abort.

This would have worked until Python was "fixed". (Equivalent code doesn't exist in Python 3.14, but at least today, in Python 3.12, this bites us). After this, the second wait() call would return immediately while the thread was still running. is_alive() also indicates the thread is dead when in fact it's still alive.

It's debatable whether the "fix" above is the right thing, but we can avoid this hairy issue by not using Thread.join() and instead use Event.wait() which we can explicitly set at the point we want the thread to be considered "done".

Without this fix, the test executor thread is still running teardowns while the output callbacks have started processing in the main thread, causing output callbacks to receive a test descriptor that hasn't been finalized - among other issues.

…t clean up properly.

To understand this bug, note that:

1. OpenHTF registers a signal handler for SIGINT
2. This handler re-raises KeyboardInterrupt
3. The `execute` function in TestDescriptor expects this, and effectively waits on the test runner thread to join - twice in the case of a manual abort.

This would have worked until [Python was "fixed"](python/cpython@a22be49#diff-b250d3d0e0d909784a67083e9069ce507513a67e8514a011e2f364027e25e0b0). (Equivalent code doesn't exist in Python 3.14, but at least today, in Python 3.12, this bites us). After this, the second wait() call would return immediately while the thread was still running. is_alive() also indicates the thread is dead when in fact it's still alive.

It's debatable whether the "fix" above is the right thing, but we can avoid this hairy issue by not using `Thread.join()` and instead use `Event.wait()` which we can explicitly set at the point we want the thread to be considered "done".

Without this fix, the test executor thread is still running teardowns while the output callbacks have started processing in the main thread, causing output callbacks to receive a test descriptor that hasn't been finalized - among other issues.

PiperOrigin-RevId: 846387423
@copybara-service copybara-service bot merged commit 7a363fb into master Dec 18, 2025
@copybara-service copybara-service bot deleted the test_846000293 branch December 18, 2025 21:10
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.

1 participant