Skip to content

Commit e79999c

Browse files
committed
git.cmd: moved hardcoded chunksize when duplicating stream data into easy-to-change class member variable
1 parent 6d9b1f4 commit e79999c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/git/cmd.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class Git(object):
3838
"""
3939
__slots__ = ("_working_dir", "cat_file_all", "cat_file_header")
4040

41+
# CONFIGURATION
42+
# The size in bytes read from stdout when copying git's output to another stream
43+
max_chunk_size = 1024*64
44+
4145
class AutoInterrupt(object):
4246
"""
4347
Kill/Interrupt the stored process instance once this instance goes out of scope. It is
@@ -173,9 +177,11 @@ def execute(self, command,
173177
If set to a file-like object, data produced by the git command will be
174178
output to the given stream directly.
175179
This feature only has any effect if as_process is False. Processes will
176-
always be created with a pipe due to issues with subprocess.
177-
This merely is a workaround as data will be copied from the
180+
always be created with a pipe as subprocess.Popen can only accept system
181+
file descriptors, not python objects ( such as StringIO ).
182+
This merely is a workaround as the data will be copied from the
178183
output pipe to the given output stream directly.
184+
See also: Git.max_chunk_size
179185
180186
``**subprocess_kwargs``
181187
Keyword arguments to be passed to subprocess.Popen. Please note that
@@ -227,7 +233,7 @@ def execute(self, command,
227233
if output_stream is None:
228234
stdout_value = proc.stdout.read().rstrip() # strip trailing "\n"
229235
else:
230-
max_chunk_size = 1024*64
236+
max_chunk_size = self.max_chunk_size
231237
while True:
232238
chunk = proc.stdout.read(max_chunk_size)
233239
output_stream.write(chunk)

0 commit comments

Comments
 (0)