Skip to content

Commit 8712c00

Browse files
authored
replace subprocess call with os.execvpe if run as separate process (#78)
1 parent 6c28811 commit 8712c00

File tree

2 files changed

+9
-20
lines changed

2 files changed

+9
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pip install https://github.com/boto/botocore/archive/v2.zip https://github.com/a
9292

9393
## Change Log
9494

95-
* v0.21: Use placeholder credentials and region only if Boto cannot not find them
95+
* v0.21: Use placeholder credentials and region only if Boto cannot not find them, fix output streaming for logs tail call
9696
* v0.20: Small fixes for Python 2.x backward compatibility
9797
* v0.19: Patch botocore to skip adding `data-` host prefixes to endpoint URLs
9898
* v0.18: Pass `SYSTEMROOT` env variable to fix "_Py_HashRandomization_Init" error on Windows

bin/awslocal

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if os.path.isdir(os.path.join(PARENT_FOLDER, '.venv')):
3131
sys.path.insert(0, PARENT_FOLDER)
3232

3333
# names of additional environment variables to pass to subprocess
34-
ENV_VARS_TO_PASS = ['PATH', 'PYTHONPATH', 'SYSTEMROOT', 'HOME']
34+
ENV_VARS_TO_PASS = ['PATH', 'PYTHONPATH', 'SYSTEMROOT', 'HOME', 'TERM', 'PAGER']
3535

3636
from localstack_client import config # noqa: E402
3737

@@ -54,24 +54,13 @@ def usage():
5454
print(__doc__.strip())
5555

5656

57-
def run(cmd, env={}):
58-
59-
def output_reader(pipe, out):
60-
out_binary = os.fdopen(out.fileno(), 'wb')
61-
with pipe:
62-
for line in iter(pipe.readline, b''):
63-
out_binary.write(line)
64-
out_binary.flush()
65-
66-
process = subprocess.Popen(
67-
cmd, env=env,
68-
stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
69-
70-
Thread(target=output_reader, args=[process.stdout, sys.stdout]).start()
71-
Thread(target=output_reader, args=[process.stderr, sys.stderr]).start()
72-
73-
process.wait()
74-
sys.exit(process.returncode)
57+
def run(cmd, env=None):
58+
"""
59+
Replaces this process with the AWS CLI process, with the given command and environment
60+
"""
61+
if not env:
62+
env = {}
63+
os.execvpe(cmd[0], cmd, env)
7564

7665

7766
def awscli_is_v1():

0 commit comments

Comments
 (0)