Skip to content

Commit

Permalink
Fixed parallel builds
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi1693 committed Jul 31, 2021
1 parent bf2a6ca commit d06bce2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def __init__(self, template, exc=None, only=None, vars=None,
self.packer = sh.Command(exec_path)
self.packer = self.packer.bake(**kwargs)

def build(self, parallel=True, debug=False, force=False,
machine_readable=False):
def build(self, parallel=True, debug=False, force=False, machine_readable=False):
"""Executes a `packer build`
:param bool parallel: Run builders in parallel
Expand All @@ -49,7 +48,7 @@ def build(self, parallel=True, debug=False, force=False,
"""
self.packer_cmd = self.packer.build

self._add_opt('-parallel-builds={}'.format(os.cpu_count()) if parallel else None)
self._add_opt('-parallel-builds={}'.format(os.cpu_count()) if parallel else 1)
self._add_opt('-debug' if debug else None)
self._add_opt('-force' if force else None)
self._add_opt('-machine-readable' if machine_readable else None)
Expand Down Expand Up @@ -112,7 +111,7 @@ def inspect(self, mrf=True):
result = self.packer_cmd()
if mrf:
result.parsed_output = self._parse_inspection_output(
result.stdout.decode())
result.stdout.decode())
else:
result.parsed_output = None
return result
Expand Down

0 comments on commit d06bce2

Please sign in to comment.