Skip to content

Commit

Permalink
Merge pull request #10 from stackhpc/fix/process-lookup-error
Browse files Browse the repository at this point in the history
Fix occasional ProcessLookupErrors when commands are cancelled
  • Loading branch information
mkjpryor authored May 14, 2024
2 parents 00347c7 + ce4711a commit 3afd3a6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pyhelm3/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,14 @@ async def run(self, command: t.List[str], input: t.Optional[bytes] = None) -> by
except asyncio.CancelledError:
# If the asyncio task is cancelled, terminate the Helm process but let the
# process handle the termination and exit
proc.terminate()
stdout, stderr = await proc.communicate()
# We occassionally see a ProcessLookupError here if the process finished between
# us being cancelled and terminating the process, which we ignore as that is our
# target state anyway
try:
proc.terminate()
_ = await proc.communicate()
except ProcessLookupError:
pass
# Once the process has exited, re-raise the cancelled error
raise
if proc.returncode == 0:
Expand Down

0 comments on commit 3afd3a6

Please sign in to comment.