So I have a list of image url's that I want to iterate over with the requests library and download all the images to a directory.
def get_image(url, image_name): path = pathlib.Path('/path/to/some/directory') response = requests.get(url, stream=True) with open('{}/{}.png'.format(path, image_name), 'wb') as file: for block in response.iter_content(1024): file.write(block) for url in urls: get_image(url, image_name) Now, is there no way I could create a decorator to make a function a callback to run once a response is returned for a specific asynchronous request?
requestsis not an asynchronous library, it is not compatible with asyncio at all.