Skip to content

Commit 25ea404

Browse files
committed
Allow user to pass "bufsize" argument to
st2common.util.green.shell.run_command() function.
1 parent 3e5f001 commit 25ea404

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

st2common/st2common/util/green/shell.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
def run_command(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False,
3939
cwd=None, env=None, timeout=60, preexec_func=None, kill_func=None,
4040
read_stdout_func=None, read_stderr_func=None,
41-
read_stdout_buffer=None, read_stderr_buffer=None, stdin_value=None):
41+
read_stdout_buffer=None, read_stderr_buffer=None, stdin_value=None,
42+
bufsize=0):
4243
"""
4344
Run the provided command in a subprocess and wait until it completes.
4445
@@ -82,6 +83,8 @@ def run_command(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
8283
using live read mode.
8384
:type read_stdout_func: ``func``
8485
86+
:param bufsize: Buffer size argument to pass to subprocess.popen function.
87+
:type bufsize: ``int``
8588
8689
:rtype: ``tuple`` (exit_code, stdout, stderr, timed_out)
8790
"""
@@ -107,7 +110,8 @@ def run_command(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
107110
# GreenPipe so it doesn't block
108111
LOG.debug('Creating subprocess.')
109112
process = concurrency.subprocess_popen(args=cmd, stdin=stdin, stdout=stdout, stderr=stderr,
110-
env=env, cwd=cwd, shell=shell, preexec_fn=preexec_func, bufsize=-1)
113+
env=env, cwd=cwd, shell=shell, preexec_fn=preexec_func,
114+
bufsize=bufsize)
111115

112116
if read_stdout_func:
113117
LOG.debug('Spawning read_stdout_func function')

0 commit comments

Comments
 (0)