Skip to content

Commit

Permalink
client.py fetching urls: stream to disk using shutil.copyfileobj
Browse files Browse the repository at this point in the history
  • Loading branch information
dstndstn committed Sep 26, 2023
1 parent 2536110 commit c4b1114
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions net/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import time
import base64
import shutil

try:
# py3
Expand Down Expand Up @@ -439,11 +440,9 @@ def jobs_by_tag(self, tag, exact):

for url,fn in retrieveurls:
print('Retrieving file from', url, 'to', fn)
f = urlopen(url)
txt = f.read()
w = open(fn, 'wb')
w.write(txt)
w.close()
with urlopen(url) as r:
with open(fn, 'wb') as w:
shutil.copyfileobj(r, w)
print('Wrote to', fn)

if opt.annotate:
Expand Down

0 comments on commit c4b1114

Please sign in to comment.