pytest-timeout
pytest-timeout copied to clipboard
timeout does not terminate the test process when used with xdist
Summary
running pytest-timeout with pytest-xdist doesn't terminate the test process.
This creates an issue if I would like to test a long-running computation-intensive function: the test process keeps running even after the timeout and the resources are not released until I manually kill the process.
Some version info from pytest
platform darwin -- Python 3.7.6, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 rootdir: /private/tmp/test_hang plugins: cov-2.10.0, xdist-1.34.0, timeout-1.4.2, forked-1.3.0 timeout: 10.0s timeout method: thread timeout func_only: False
To reproduce
Create a simple test case (test_simple_hang.py) like this:
import time
import os
def test():
print(os.getpid())
time.sleep(60)
Running the following command:
pytest --timeout=10 --boxed --timeout_method=thread test_simple_hang.py
After the timeout, if I do ps -ef | grep <pid>
, the process remains active.
It also occurs when --timeout_method=signal
.
Is it related with https://github.com/pytest-dev/pytest/issues/6887 ?