node2:/root/python3#cat p17.py
import requests
import time
def download_one(url):
resp = requests.get(url)
time.sleep(2)
print('Read {} from {}'.format(len(resp.content), url))
def download_all(sites):
for site in sites:
download_one(site)
def main():
sites = [
'http://192.168.137.3:9000',
'http://192.168.137.3:9000',
'http://192.168.137.3:9000',
]
start_time = time.perf_counter()
download_all(sites)
end_time = time.perf_counter()
print('Download {} sites in {} seconds'.format(len(sites), end_time - start_time))
if __name__ == '__main__':
main()
node2:/root/python3#time python3 p17.py
Read 1194 from http://192.168.137.3:9000
Read 1194 from http://192.168.137.3:9000