Skip to content

Instantly share code, notes, and snippets.

@ethe
Last active August 13, 2019 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethe/700e289915a59ad976af128ecd91113b to your computer and use it in GitHub Desktop.
Save ethe/700e289915a59ad976af128ecd91113b to your computer and use it in GitHub Desktop.
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