Skip to content

Commit f821783

Browse files
committed
Killing timeouted processes
1 parent bda9390 commit f821783

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

arca/backend/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ def run(self, repo: str, branch: str, task: Task, git_repo: Repo, repo_path: Pat
165165
stderr=subprocess.PIPE,
166166
cwd=cwd)
167167

168-
out_stream, err_stream = process.communicate(timeout=task.timeout)
168+
try:
169+
out_stream, err_stream = process.communicate(timeout=task.timeout)
170+
except subprocess.TimeoutExpired:
171+
process.kill()
172+
raise BuildTimeoutError(f"The task timeouted after {task.timeout} seconds.")
169173

170174
out_output = out_stream.decode("utf-8")
171175
err_output = err_stream.decode("utf-8")
@@ -174,9 +178,7 @@ def run(self, repo: str, branch: str, task: Task, git_repo: Repo, repo_path: Pat
174178
logger.debug(out_output)
175179

176180
return Result(out_output)
177-
except subprocess.TimeoutExpired:
178-
raise BuildTimeoutError(f"The task timeouted after {task.timeout} seconds.")
179-
except BuildError: # can be raised by :meth:`Result.__init__`
181+
except BuildError: # can be raised by :meth:`Result.__init__` or by timeout
180182
raise
181183
except Exception as e:
182184
logger.exception(e)

arca/backend/current_environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def install_requirements(self, *, path: Optional[Path] = None, requirements: Opt
7979
try:
8080
out_stream, err_stream = process.communicate(timeout=self.requirements_timeout)
8181
except subprocess.TimeoutExpired:
82+
process.kill()
8283
raise BuildTimeoutError(f"Installing of requirements timeouted after {self.requirements_timeout} seconds.")
8384

8485
out_stream = out_stream.decode("utf-8")

arca/backend/venv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def get_or_create_venv(self, path: Path) -> Path:
6969
try:
7070
out_stream, err_stream = process.communicate(timeout=self.requirements_timeout)
7171
except subprocess.TimeoutExpired:
72+
process.kill()
7273
shutil.rmtree(venv_path, ignore_errors=True)
7374

7475
raise BuildTimeoutError(f"Installing of requirements timeouted after "

0 commit comments

Comments
 (0)