I had a for-loop that would take a URL from a set of URLs and reach out to that URL and do some other stuff, but it was taking forever, so I figured I'd speed it up with some multiprocessing, but am struggling to do so.
Thank you for any assistance.
def accessAndSaveFiles(urlSet, user, verboseFlag):
with multiprocessing.Pool(os.cpu_count()) as pool:
pool.starmap(processURL, zip(itertools.repeat(urlSet), user, verboseFlag))
def processURL(url, user, verboseFlag):
filePath = some_path
img_data = requests.get(url, allow_redirects=True)
open(filePath, 'wb').write(img_data.content)
def main():
...
accessAndSaveFiles(urlSet, user, verboseFlag)
...
I get an error on the "pool.starmap(processURL, zip(itertools.repeat(urlSet), user, verboseFlag))" line saying "TypeError: zip argument #3 must support iteration". I don't want to iterate over this item, I just want to send the same value every time.