pytest-dev / pytest-dev/pytest-timeout
hanging when I use --time-methid=signal
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 258
- Forks
- 69
- PR merge metrics
- No merged PRs in 30d
Description
i am making a unittest,
`for index, test_case in enumerate(test_cases[start_case_index:], start=start_case_index):
test_case_name = test_case.split("::")[-1]
print(f"Running {test_case_name}")
pytest.main(['-v', '--tb=short', '--capture=no', '--timeout=20', '--timeout-method=signal', test_case], plugins=[recorder])
result_data = recorder.results.get(test_case)
if result_data is None:
result_data = {
"outcome": "not executed",
"duration": 0,
"timestamp": datetime.now().isoformat()
}`
above is my test code, if one case is out of time, the process will hang and show log like below and would not break out to next test case,what shoukd I do?
++++++++++++++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++++++++++++
File "/usr/lib/python3.10/threading.py", line 973, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3.10/concurrent/futures/thread.py", line 83, in _worker
work_item.run()
File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/workspace/bailuan/20240105_iree_chiptech/iree/tests/e2e/dlc_specific/test_runner.py", line 461, in thread_task
result = run_test(fn, inputs, output_num, global_config_path,
File "/workspace/bailuan/20240105_iree_chiptech/iree/tests/e2e/dlc_specific/test_runner.py", line 428, in run_test
output_fns1 = run_in_backend("dlc")
File "/workspace/bailuan/20240105_iree_chiptech/iree/tests/e2e/dlc_specific/test_runner.py", line 406, in run_in_backend
run_result = subprocess.run(
File "/usr/lib/python3.10/subprocess.py", line 505, in run
stdout, stderr = process.communicate(input, timeout=timeout)
File "/usr/lib/python3.10/subprocess.py", line 1154, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/lib/python3.10/subprocess.py", line 2021, in _communicate
ready = selector.select(timeout)
File "/usr/lib/python3.10/selectors.py", line 416, in select
fd_event_list = self._selector.poll(timeout)
++++++++++++++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++++++++++++
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
Reproduce the hang with the shown pytest.main loop and --timeout-method=signal, then inspect the timeout output from iree/tests/e2e/dlc_specific/test_runner.py, especially thread_task, run_test, run_in_backend, and subprocess.run. Trace how the timed-out worker and subprocess are handled; done means a timed-out case returns control to the loop and the next test case runs without leaving the process hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100