Skip to content

Allow max_chunk_size to be configurable #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexandernst opened this issue Jul 25, 2017 · 1 comment
Closed

Allow max_chunk_size to be configurable #648

alexandernst opened this issue Jul 25, 2017 · 1 comment

Comments

@alexandernst
Copy link

alexandernst commented Jul 25, 2017

Here max_chunk_size will usually contain (depending on the platform) 8192, which is a very high value for a chunk and won't trigger a .write (keep reading) until quite some output is printed to stdout. I propose to make that value configurable (maybe via an argument).

My use case:

I have the following class:

class PipeIO(io.BytesIO):
	def __init__(self, cb):
		io.BytesIO.__init__(self)
		self.updater_cb = cb

	def write(self, b):
		buf = io.BytesIO.getbuffer(self).tobytes()
		progress = re.findall("(?<=\()\d+\/\d+(?=\))", buf.decode("utf-8"))

		try:
			self.updater_cb(progress[-1])
		except:
			pass

		return io.BytesIO.write(self, b)

And I use it like this:

stdout = PipeIO(self.my_updater_callback)
self.repo.git.filter_branch("-f", "--env-filter", s, output_stream = stdout)

This will cause my callback to parse the content of the buffer every time .write is called, which is very useful if I want to provide progress updates while running a long git command (like filter-branch).

Possible solution:

Make it possible to call raw commands with one extra argument:

self.repo.git.filter_branch("-f", "--env-filter", s, output_stream = stdout, max_chunk_size = 32)
@Byron
Copy link
Member

Byron commented Sep 28, 2017

Thanks for your suggestion. It should be relatively straightforward to make this value configurable, and I would be happy about a PR.

bpiotr added a commit to bpiotr/GitPython that referenced this issue Oct 3, 2017
bpiotr added a commit to bpiotr/GitPython that referenced this issue Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants