Understand timeout methods: thread vs signal
mainThe plugin uses different methods to interrupt tests. If a method fails, the thread method is the safest fallback.
thread
- How it works: Starts a timer thread that terminates the entire process after the timeout.
- Pros: Most portable and surest method; always works.
- Cons: High overhead; terminates the entire process, meaning fixture teardown and JUnit XML output will not complete normally.
signal
- How it works: Uses
SIGALRMto schedule an alarm. If the alarm expires, it dumps thread stacks to stderr and callspytest.fail()to interrupt the test. - Pros: The pytest process is not terminated, allowing the test run to complete normally.
- Cons: May interfere with code that uses
SIGALRMitself.