Skip to content

Instantly share code, notes, and snippets.

@delijati
Created October 31, 2014 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delijati/e1ff03c3ad40dfe225ba to your computer and use it in GitHub Desktop.
Save delijati/e1ff03c3ad40dfe225ba to your computer and use it in GitHub Desktop.
Git pull with auth is slow with PIPE
import tempfile
import subprocess
import timeit
class GitWorkerPipe(object):
def start(self):
cmd = subprocess.Popen(["git", "pull"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
print(cmd.stdout.read())
print(cmd.stderr.read())
cmd.wait()
class GitWorkerTemp(object):
def start(self):
my_stderr = tempfile.TemporaryFile()
my_stdout = tempfile.TemporaryFile()
cmd = subprocess.Popen(["git", "pull"], stdout=my_stdout,
stderr=my_stderr)
cmd.wait()
my_stdout.seek(0)
my_stderr.seek(0)
print(cmd.returncode)
print(my_stdout.read())
print(my_stderr.read())
my_stdout.close()
my_stderr.close()
def main():
t = timeit.Timer(GitWorkerPipe().start)
print(t.timeit(1))
t = timeit.Timer(GitWorkerTemp().start)
print(t.timeit(1))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment