[hca] Join threads before closing file descriptor

In some environments, heat container agent is erroring because of file
descriptor closing before threads have joined.

Change-Id: I1de5042ea5f4229518e96b985b1832dcacb052db
Story: 2007264
Task: 39788
This commit is contained in:
Bharat Kunwar 2020-05-15 07:03:10 +00:00
parent 81d0699c4c
commit 2e1811861b

View File

@ -87,9 +87,14 @@ def main(argv=sys.argv):
logger = dict(stdout=lambda line: log.info(line),
stderr=lambda line: log.debug(line))
with open(lp, 'w') as fd:
for label in ['stdout', 'stderr']:
threading.Thread(target=consumer, args=[label, fd]).start()
threads = []
for lb in ['stdout', 'stderr']:
t = threading.Thread(target=consumer, args=[lb, fd])
threads.append(t)
t.start()
deploy_status_code = subproc.wait()
for t in threads:
t.join()
if deploy_status_code:
log.error("Error running %s. [%s]\n" % (fn, deploy_status_code))