Multithreading via decorator.
import time
import requests
from tomorrow import threads
@threads(5, timeout=0.1) # just adding simple line of code
def download(url):
return requests.get(url)
if __name__ == "__main__":
start = time.time()
responses = [download(url) for url in urls]
html = [response.text for response in responses]
end = time.time()
print("Time: %f seconds" % (end - start))