Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

timeout does not terminate the test process when used with xdist

未关闭
#72 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
testing-qa

调研方向

从 test_simple_hang.py 中复现的测试开始,使用 thread 和 signal 两种 timeout 方法运行文档中说明的 pytest 命令。检查 timeout 在 --boxed 和 xdist 下的行为;完成的标准是,发生 timeout 的测试进程会终止并释放其资源,而不是继续保持活动状态。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
260
派生
70
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pytest-dev/pytest-timeout 的其他 Issue

查看 pytest-dev/pytest-timeout 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。