|
47 | 47 | execute_kwargs = set(('istream', 'with_extended_output',
|
48 | 48 | 'with_exceptions', 'as_process', 'stdout_as_string',
|
49 | 49 | 'output_stream', 'with_stdout', 'kill_after_timeout',
|
50 |
| - 'universal_newlines', 'shell', 'env')) |
| 50 | + 'universal_newlines', 'shell', 'env', 'max_chunk_size')) |
51 | 51 |
|
52 | 52 | log = logging.getLogger(__name__)
|
53 | 53 | log.addHandler(logging.NullHandler())
|
@@ -175,8 +175,6 @@ def __setstate__(self, d):
|
175 | 175 | dict_to_slots_and__excluded_are_none(self, d, excluded=self._excluded_)
|
176 | 176 |
|
177 | 177 | # CONFIGURATION
|
178 |
| - # The size in bytes read from stdout when copying git's output to another stream |
179 |
| - max_chunk_size = io.DEFAULT_BUFFER_SIZE |
180 | 178 |
|
181 | 179 | git_exec_name = "git" # default that should work on linux and windows
|
182 | 180 |
|
@@ -598,6 +596,7 @@ def execute(self, command,
|
598 | 596 | universal_newlines=False,
|
599 | 597 | shell=None,
|
600 | 598 | env=None,
|
| 599 | + max_chunk_size=None, |
601 | 600 | **subprocess_kwargs
|
602 | 601 | ):
|
603 | 602 | """Handles executing the command on the shell and consumes and returns
|
@@ -643,6 +642,11 @@ def execute(self, command,
|
643 | 642 |
|
644 | 643 | :param env:
|
645 | 644 | A dictionary of environment variables to be passed to `subprocess.Popen`.
|
| 645 | + |
| 646 | + :param max_chunk_size: |
| 647 | + Maximum number of bytes in one chunk of data passed to the output_stream in |
| 648 | + one invocation of write() method. If the given number is not positive then |
| 649 | + the default value is used. |
646 | 650 |
|
647 | 651 | :param subprocess_kwargs:
|
648 | 652 | Keyword arguments to be passed to subprocess.Popen. Please note that
|
@@ -789,7 +793,8 @@ def _kill_process(pid):
|
789 | 793 | stderr_value = stderr_value[:-1]
|
790 | 794 | status = proc.returncode
|
791 | 795 | else:
|
792 |
| - stream_copy(proc.stdout, output_stream, self.max_chunk_size) |
| 796 | + max_chunk_size = max_chunk_size if max_chunk_size and max_chunk_size > 0 else io.DEFAULT_BUFFER_SIZE |
| 797 | + stream_copy(proc.stdout, output_stream, max_chunk_size) |
793 | 798 | stdout_value = output_stream
|
794 | 799 | stderr_value = proc.stderr.read()
|
795 | 800 | # strip trailing "\n"
|
|
0 commit comments