Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
approxit committed Mar 15, 2024
1 parent a2f716b commit fd59f28
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ray_on_golem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,17 @@ async def run_subprocess_output(*args, timeout: Optional[timedelta] = None) -> b
stderr=asyncio.subprocess.PIPE,
)

stdout, stderr = await asyncio.wait_for(
process.communicate(),
timeout.total_seconds() if timeout else None,
)
try:
stdout, stderr = await asyncio.wait_for(
process.communicate(),
timeout.total_seconds() if timeout else None,
)
except asyncio.TimeoutError as e:
if process.returncode is None:
process.kill()
await process.wait()

raise RayOnGolemError(f"Process could not finish in timeout of {timeout}!") from e

if process.returncode != 0:
raise RayOnGolemError(
Expand Down

0 comments on commit fd59f28

Please sign in to comment.