pytest-dev / pytest-dev/pytest-timeout
timeout does not terminate the test process when used with xdist
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 258
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduced test in test_simple_hang.py and run the documented pytest command with both thread and signal timeout methods. Inspect how the timeout behaves with --boxed and xdist; done means the timed-out test process terminates and releases its resources instead of remaining active.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100