Skip to content

Instantly share code, notes, and snippets.

@akshaykarnawat
Created October 11, 2017 02:52
Show Gist options
  • Save akshaykarnawat/e2e170417217620cad1de30a88432fe4 to your computer and use it in GitHub Desktop.
Save akshaykarnawat/e2e170417217620cad1de30a88432fe4 to your computer and use it in GitHub Desktop.
Multi-Processing in python
from multiprocessing.pool import Pool
import requests
import time
def page(symbol):
requests.get(url='https://finviz.com/quote.ashx?t=' + symbol)
start = time.time()
p = Pool()
p.map(page, ['AAPL', 'AMZN', 'GOOG', 'MSFT', 'FB'])
print (time.time() - start)
# #takes longer
# start = time.time()
# for x in ['AAPL', 'AMZN', 'GOOG', 'MSFT', 'FB']:
# page(x)
# print (time.time() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment