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