fix(core): handle intermittent signal interrupt test failures - #5273
fix(core): handle intermittent signal interrupt test failures#5273eshaanag wants to merge 2 commits into
Conversation
Remove the short option '-c' from the --config-file option registration. This resolves a conflict with the --copyright short option '-c', which triggered duplicate parameter registration warnings under click. Signed-off-by: Eshaan Agrawal <agrawaleshaan12@gmail.com>
Catch ValueError raised when calling signal.signal from a non-main thread or non-main interpreter context (e.g. sub-interpreters on Python 3.14+). Falls back to synchronous execution without a timeout. Signed-off-by: Eshaan Agrawal <agrawaleshaan12@gmail.com>
25ccb9f to
43f02c6
Compare
|
@eshaanag thanks for the PR, you've added interrupt related changes which are unrelated and should have been a seperate PR, so we've merged #5279 instead. Could you update the PR description and title to address only the signal inturrupt related changes? Also I've not seen this failure consistently but only happening sometimes, can you explain that? Like for example all tests passed in https://github.com/aboutcode-org/scancode-toolkit/runs/98624035607 without this. |
|
@AyanSinhaMahapatra The PR title and description have been updated to reflect only the signal interrupt changes. Regarding the inconsistent test failures: |
This pull request modifies the interrupt handling implementation in
src/scancode/interrupt.pyby removing the reliance onPyThreadState_SetAsyncExc.The
PyThreadState_SetAsyncExcAPI is non-deterministic. Injecting asynchronous exceptions into threads relies on the Python GIL state. If a thread is blocked in a system call or C extension without releasing the GIL correctly, the exception is delayed and may trigger during test teardown or critical sections. This leads to inconsistent race conditions and intermittent SIGINT test failures across different CI runner environments.Changes:
PyThreadState_SetAsyncExclogic ininterrupt.py.