Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Use try/finally to make sure that the running container gets killed
Browse files Browse the repository at this point in the history
  • Loading branch information
adikus committed Jan 13, 2020
1 parent a93a47d commit 1662c40
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lambdipy/project_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ def _run_command_in_docker(command, build_directory, python_version):
)
cli.start(container=container.get('Id'))

command_exec = cli.exec_create(container=container.get('Id'), cmd=command)
command_runtime = cli.exec_start(exec_id=command_exec.get('Id'), stream=True)

for line in command_runtime:
print(line.decode('utf-8'), end='')

cli.kill(container.get('Id'))
cli.remove_container(container.get('Id'))
try:
command_exec = cli.exec_create(container=container.get('Id'), cmd=command)
command_runtime = cli.exec_start(exec_id=command_exec.get('Id'), stream=True)

for line in command_runtime:
print(line.decode('utf-8'), end='')
finally:
cli.kill(container.get('Id'))
cli.remove_container(container.get('Id'))


def install_non_resolved_requirements(resolved_requirements, requirements, python_version, keep_tests=None, no_docker=False,
Expand Down

0 comments on commit 1662c40

Please sign in to comment.