fixed hcl2 process not finishing in case of an exception
@@ -668,7 +668,12 @@ def _hcl2_load_with_timeout(f: io.TextIOWrapper) -> Dict:
q = Queue() # used by the child process to return its result
p = Process(target=_hcl2_load, args=(q, f))
p.start()
+ try:
raw_data = q.get(block=True, timeout=60) # Wait until the file is parsed, up to 60 seconds. A timeout will raise a queue.Empty exception
+ except Exception as e:
+ if p.is_alive():
+ p.terminate() # aggressive termination of process for cleanup
+ raise e
p.join() # Make sure the process is finished and closed
return raw_data
@@ -682,6 +687,7 @@ def _hcl2_load(q: Queue, f: io.TextIOWrapper) -> None:
logging.error(e, exc_info=True)
q.put(None)
+
def _is_valid_block(block):
if not isinstance(block, dict):
return True
