Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from urllib.request import urlretrieve
- import requests
- from multiprocessing import Pool
- def download(i):
- try:
- headers = requests.head("http://www.site.com/scripts/getfile.php?id={}".format(i))
- except:
- print("Unable to reach file " + str(i))
- return None
- try:
- filename = headers.headers["content-disposition"].replace("filename=", "")
- filename = "{}_{}".format(i, filename)
- except:
- filename = str(i)
- urlretrieve("http://www.site.com/scripts/getfile.php?id={}".format(i), "/Volumes/SeagateExpansion/Database/{}".format(filename))
- print("Downloaded {}".format(filename))
- p = Pool(processes = 16)
- p.map(download, range(70000))
- p.close()
- p.join()
- ERROR:
- Traceback (most recent call last):
- File "/Users/MyUsername/Dropbox/Python/Projects/FileDownloader.py", line 20, in <module>
- p.map(download, range(70000))
- File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/multiprocessing/pool.py", line 260, in map
- return self._map_async(func, iterable, mapstar, chunksize).get()
- File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/multiprocessing/pool.py", line 599, in get
- raise self._value
- multiprocessing.pool.MaybeEncodingError: Error sending result: '<multiprocessing.pool.ExceptionWithTraceback object at 0x1027a67f0>'. Reason: 'TypeError("cannot serialize '_io.BufferedReader' object",)'
Advertisement
Add Comment
Please, Sign In to add comment