145
145
except UnlockError:
148
def copyfileobj(infp, outfp, byte_count = -1):
149
"""Copy byte_count bytes from infp to outfp, or all if byte_count < 0
151
Returns the number of bytes actually written (may be less than
152
byte_count if find eof. Does not close either fileobj.
155
blocksize = 64 * 1024
159
buf = infp.read(blocksize)
162
bytes_written += len(buf)
165
while bytes_written + blocksize <= byte_count:
166
buf = infp.read(blocksize)
169
bytes_written += len(buf)
171
buf = infp.read(byte_count - bytes_written)
172
bytes_written += len(buf)