Skip to content

Instantly share code, notes, and snippets.

@abhirama
Last active March 31, 2020 09:03
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 abhirama/d7a69964183a166b6c58e50fe1e0bc7d to your computer and use it in GitHub Desktop.
Save abhirama/d7a69964183a166b6c58e50fe1e0bc7d to your computer and use it in GitHub Desktop.
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