From 0b2eb3b1be8153ce4ea115ab7596df736c824b95 Mon Sep 17 00:00:00 2001 From: Raquel Alegre Date: Fri, 11 Aug 2017 19:00:06 +0100 Subject: [PATCH] Return a reference to the subprocess so output can be handled from elsewhere. --- python_terraform/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python_terraform/__init__.py b/python_terraform/__init__.py index 35c6e3b..144a735 100644 --- a/python_terraform/__init__.py +++ b/python_terraform/__init__.py @@ -235,6 +235,11 @@ class Terraform(object): p = subprocess.Popen(cmd_string, stdout=stdout, stderr=stderr, shell=True, cwd=working_folder, env=environ_vars) + + synchronous = kwargs.pop('synchronous', True) + if not synchronous: + return p, None, None + out, err = p.communicate() ret_code = p.returncode log.debug('output: {o}'.format(o=out))