I'm hosting a server on localhost and I want to fire hundreds of GET requests asynchronously. For this I am using grequests
. Everything appears to work fine but I repeatedly get the warning:
WARNING:requests.packages.urllib3.connectionpool:Connection pool is full, discarding connection: date.jsontest.com
A search shows how the full pool issue can be avoided when creating a Session()
in requests
e.g. here. However, a couple of things:
- Even if I don't take any steps to avoid the warning, I appear to consistently get the expected results. If I do use the workaround, any requests over the number of the
pool_maxsize
will give a warning. - The linked workaround will still result in the warning if the number of requests exceeds the pool size. I assumed there would be some kind of throttling to prevent the pool size being exceeded at any one time
- I can't seem to find a way to disable the warning.
requests.packages.urllib3.disable_warnings()
doesn't seem to do anything.
So my questions are:
- What does this warning actually mean? My interpretation is that it is simply dropping the requests from firing, but it doesn't seem to be the case.
- Is this warning actually relevant for the
grequests
library, especially when I take steps to limit the pool size? Am I inviting unexpected behaviour and fluking my expected result in my tests? - Is there a way to disable it?
Some code to test:
import grequests
import requests
requests.packages.urllib3.disable_warnings() # Doesn't seem to work?
session = requests.Session()
# Hashing the below will cause 105 warnings instead of 5
adapter = requests.adapters.HTTPAdapter(pool_connections=100,
pool_maxsize=100)
session.mount('http://', adapter)
# Test query
query_list = ['http://date.jsontest.com/' for x in xrange(105)]
rs = [grequests.get(item, session=session) for item in query_list]
responses = grequests.map(rs)
print len([item.json() for item in responses])