Calling `f.read()` would read the entire file at once which is
wasteful. It's also not intended given the read loop.
Also replace a use of `readline()` with `read(65536)` as well where we
want to read the entire file and not only single lines.
def pipe_file(f, t):
f.seek(0)
while 1:
- l = f.read()
+ l = f.read(65536)
if not l: break
t.write(l)
t.close()
def create_temp_file(r):
f = tempfile.TemporaryFile()
while 1:
- x = r.readline()
+ x = r.read(65536)
if not x: break
f.write(x)
r.close()