Skip to content

Commit

Permalink
fix: 插件测试时设置为 10 分钟超时
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Apr 10, 2024
1 parent daf3d1e commit f3896dd
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/utils/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""
# ruff: noqa: T201, ASYNC101

import asyncio
import json
import os
import re
Expand Down Expand Up @@ -245,15 +246,21 @@ async def run_poetry_project(self) -> None:
)
)

proc = await create_subprocess_shell(
"poetry run python runner.py",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.path,
env=self.get_env(),
)
stdout, stderr = await proc.communicate()
code = proc.returncode
try:
proc = await create_subprocess_shell(
"poetry run python runner.py",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=self.path,
env=self.get_env(),
)
stdout, stderr = await asyncio.wait_for(proc.communicate(), timeout=600)
code = proc.returncode
except asyncio.TimeoutError:
proc.terminate()
stdout = b""
stderr = "测试超时".encode()
code = 1

self._run = not code

Expand Down

0 comments on commit f3896dd

Please sign in to comment.