Use a Session to enable connection pooling
Use a Session to enable connection pooling

Requests and urllib3 automatically reuse connections if using a Session, which otherwise has all the same methods as the main Requests API, making this a drop-in replacement: http://docs.python-requests.org/en/latest/user/advanced/

In my tests, this change cut 830 HEAD requests to Foursquare's internal artifact cache from 22s to 11s.

Testing Done:
Using 830 cache keys copied from a real build, this change cut the time to do HEAD requests for each from 22s to 11s.

https://travis-ci.org/pantsbuild/pants/builds/38515947

Reviewed at https://rbcommons.com/s/twitter/r/981/

cevaris/pants,jsirois/pants,sameerparekh/pants,laurentgo/pants,tejal29/pants,dgomez10/xanon,areitz/pants,pgroudas/pants,wisechengyi/pants,fkorotkov/pants,dgomez10/xanon,Gabriel439/pants,lahosken/pants,tdyas/pants,slyphon/pants,pombredanne/pants,landism/pants,kwlzn/pants,sameerparekh/pants,scode/pants,twitter/pants,laurentgo/pants,jessrosenfield/pants,ericzundel/pants,wisechengyi/pants,TansyArron/pants,di0spyr0s/pants,jtrobec/pants,jessrosenfield/pants,twitter/pants,ericzundel/pants,tdyas/pants,jessrosenfield/pants,mateor/pants,dbentley/pants,landism/pants,landism/pants,pombredanne/pants,pgroudas/pants,ericzundel/pants,square/pants,slyphon/pants,peiyuwang/pants,laurentgo/pants,wisechengyi/pants,scode/pants,landism/pants,pantsbuild/pants,peiyuwang/pants,twitter/pants,gmalmquist/pants,mateor/pants,UnrememberMe/pants,qma/pants,15Dkatz/pants,sid-kap/pants,qma/pants,kslundberg/pants,manasapte/pants,ity/pants,ericzundel/pants,tdyas/pants,tejal29/pants,mateor/pants,kwlzn/pants,kslundberg/pants,kwlzn/pants,pantsbuild/pants,areitz/pants,megaserg/pants,manasapte/pants,fkorotkov/pants,baroquebobcat/pants,pantsbuild/pants,pgroudas/pants,baroquebobcat/pants,digwanderlust/pants,TansyArron/pants,ericzundel/pants,benjyw/pants,manasapte/pants,scode/pants,manasapte/pants,kwlzn/pants,tdyas/pants,Gabriel439/pants,digwanderlust/pants,UnrememberMe/pants,megaserg/pants,15Dkatz/pants,kslundberg/pants,megaserg/pants,dturner-tw/pants,lahosken/pants,UnrememberMe/pants,di0spyr0s/pants,foursquare/pants,mateor/pants,landism/pants,peiyuwang/pants,gmalmquist/pants,dgomez10/xanon,laurentgo/pants,gmalmquist/pants,dbentley/pants,dbentley/pants,tejal29/pants,gmalmquist/pants,cevaris/pants,mateor/pants,dbentley/pants,scode/pants,dgomez10/xanon,mateor/pants,foursquare/pants,jsirois/pants,ericzundel/pants,lahosken/pants,TansyArron/pants,wisechengyi/pants,di0spyr0s/pants,sameerparekh/pants,dturner-tw/pants,wisechengyi/pants,dturner-tw/pants,lahosken/pants,di0spyr0s/pants,gmalmquist/pants,dgomez10/xanon,foursquare/pants,foursquare/pants,qma/pants,foursquare/pants,twitter/pants,dbentley/pants,dgomez10/xanon,tejal29/pants,qma/pants,sid-kap/pants,tdyas/pants,kwlzn/pants,slyphon/pants,dgomez10/xanon,megaserg/pants,areitz/pants,landism/pants,slyphon/pants,qma/pants,digwanderlust/pants,wisechengyi/pants,sid-kap/pants,jsirois/pants,landism/pants,jessrosenfield/pants,fkorotkov/pants,manasapte/pants,jtrobec/pants,megaserg/pants,15Dkatz/pants,pombredanne/pants,areitz/pants,baroquebobcat/pants,TansyArron/pants,baroquebobcat/pants,benjyw/pants,pantsbuild/pants,jtrobec/pants,di0spyr0s/pants,fkorotkov/pants,jessrosenfield/pants,TansyArron/pants,15Dkatz/pants,ericzundel/pants,ity/pants,pombredanne/pants,pgroudas/pants,wisechengyi/pants,kslundberg/pants,jtrobec/pants,Gabriel439/pants,areitz/pants,peiyuwang/pants,peiyuwang/pants,mateor/pants,slyphon/pants,baroquebobcat/pants,manasapte/pants,peiyuwang/pants,dgomez10/xanon,ity/pants,15Dkatz/pants,megaserg/pants,fkorotkov/pants,manasapte/pants,benjyw/pants,ity/pants,benjyw/pants,tdyas/pants,square/pants,peiyuwang/pants,wisechengyi/pants,jtrobec/pants,TansyArron/pants,tdyas/pants,TansyArron/pants,pgroudas/pants,twitter/pants,UnrememberMe/pants,jessrosenfield/pants,UnrememberMe/pants,gmalmquist/pants,wisechengyi/pants,landism/pants,dturner-tw/pants,di0spyr0s/pants,ericzundel/pants,ity/pants,Gabriel439/pants,pgroudas/pants,peiyuwang/pants,jtrobec/pants,dbentley/pants,megaserg/pants,foursquare/pants,twitter/pants,sameerparekh/pants,tdyas/pants,baroquebobcat/pants,digwanderlust/pants,laurentgo/pants,lahosken/pants,tejal29/pants,gmalmquist/pants,square/pants,dturner-tw/pants,lahosken/pants,fkorotkov/pants,kslundberg/pants,foursquare/pants,lahosken/pants,mateor/pants,pombredanne/pants,areitz/pants,UnrememberMe/pants,sameerparekh/pants,kwlzn/pants,qma/pants,15Dkatz/pants,scode/pants,benjyw/pants,benjyw/pants,areitz/pants,cevaris/pants,jtrobec/pants,slyphon/pants,15Dkatz/pants,twitter/pants,cevaris/pants,lahosken/pants,sid-kap/pants,slyphon/pants,Gabriel439/pants,di0spyr0s/pants,Gabriel439/pants,baroquebobcat/pants,ity/pants,pantsbuild/pants,fkorotkov/pants,cevaris/pants,Gabriel439/pants,15Dkatz/pants,digwanderlust/pants,baroquebobcat/pants,pombredanne/pants,baroquebobcat/pants,dgomez10/xanon,cevaris/pants,sameerparekh/pants,kslundberg/pants,pombredanne/pants,dbentley/pants,dturner-tw/pants,fkorotkov/pants,jessrosenfield/pants,kslundberg/pants,square/pants,UnrememberMe/pants,pantsbuild/pants,scode/pants,UnrememberMe/pants,foursquare/pants,kwlzn/pants,sid-kap/pants,sid-kap/pants,dgomez10/xanon,laurentgo/pants,cevaris/pants,ity/pants,pantsbuild/pants,tdyas/pants,UnrememberMe/pants,scode/pants,benjyw/pants,sameerparekh/pants,twitter/pants,sid-kap/pants,qma/pants,twitter/pants,foursquare/pants,dgomez10/xanon,digwanderlust/pants,dturner-tw/pants