Skip to content

Commit

Permalink
On subprocess kill write exit code to result to prevent changes (#120)
Browse files Browse the repository at this point in the history
* fix missed docstring
  • Loading branch information
penguinolog committed Dec 11, 2018
1 parent f4908a5 commit fb0ef72
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
8 changes: 2 additions & 6 deletions exec_helpers/async_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,8 @@ async def _exec_command( # type: ignore
:param command: Command for execution
:type command: str
:param interface: Control interface
:type interface: typing.Any
:param stdout: STDOUT pipe or file-like object
:type stdout: typing.Optional[asyncio.StreamReader]
:param stderr: STDERR pipe or file-like object
:type stderr: typing.Optional[asyncio.StreamReader]
:param async_result: execute_async result
:type async_result: ExecuteAsyncResult
:param timeout: Timeout for command execution
:type timeout: typing.Union[int, float, None]
:param verbose: produce verbose log record on command call
Expand Down
1 change: 1 addition & 0 deletions exec_helpers/async_api/subprocess_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ async def poll_stderr() -> None:
exit_code = await asyncio.wait_for(async_result.interface.wait(), timeout=0.001)
if exit_code is None:
raise exceptions.ExecHelperNoKillError(result=result, timeout=timeout)
result.exit_code = exit_code
finally:
stdout_task.cancel()
stderr_task.cancel()
Expand Down
1 change: 1 addition & 0 deletions exec_helpers/subprocess_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def close_streams() -> None:
exit_code = async_result.interface.poll()
if exit_code is None:
raise exceptions.ExecHelperNoKillError(result=result, timeout=timeout)
result.exit_code = exit_code
finally:
stdout_future.cancel()
stderr_future.cancel()
Expand Down

0 comments on commit fb0ef72

Please sign in to comment.