[email protected] wrote: > But how to read chunks?
Instead of
> data = response.read() # a `bytes` object
> out_file.write(data)
use a loop:
CHUNKSIZE = 16*1024 # for example
while True:
data = response.read(CHUNKSIZE)
if not data:
break
out_file.write(data)
This can be simplified:
shutil.copyfileobj(response, out_file)
https://docs.python.org/dev/library/shutil.html#shutil.copyfileobj
--
https://mail.python.org/mailman/listinfo/python-list
