Last active
March 31, 2020 09:03
-
-
Save abhirama/d7a69964183a166b6c58e50fe1e0bc7d 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
import requests | |
from requests.adapters import HTTPAdapter | |
import threading | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
s = requests.session() | |
def call(url): | |
s.get(url) | |
s.mount("https://", HTTPAdapter(pool_connections=1, pool_maxsize=2)) | |
t0 = threading.Thread(target=call, args=("https://api.github.com", )) | |
t1 = threading.Thread(target=call, args=("https://api.github.com", )) | |
t0.start() | |
t1.start() | |
t0.join() | |
t1.join() | |
t2 = threading.Thread(target=call, args=("https://api.github.com", )) | |
t3 = threading.Thread(target=call, args=("https://api.github.com", )) | |
t2.start() | |
t3.start() | |
t2.join() | |
t3.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment