Last active
August 13, 2019 11:10
-
-
Save ethe/700e289915a59ad976af128ecd91113b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
import requests | |
def process_url(url): | |
print('start') | |
requests.get(url) | |
print('done') | |
return | |
if __name__ == '__main__': | |
urls_to_download = 'https://baidu.com' | |
PARALLEL_WORKERS = 1 | |
pool = Pool(PARALLEL_WORKERS) | |
result = pool.apply_async(process_url, (urls_to_download,)) | |
result.get() | |
pool.close() | |
pool.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment