我正在使用带有会话的Python请求库:
def _get_session(self):
if not self.session:
self.session = requests.Session()
return self.session
有时候在我的日志中会看到这个警告:
[2014/May/12 14:40:04 WARNING ] HttpConnectionPool is full, discarding connection: www.ebi.ac.uk
我的问题是:为什么这是一个警告而不是异常?
这是代码负责的(来自http://pydoc.net/Python/requests/0.8.5/requests.packages.urllib3.connectionpool/):
def _put_conn(self, conn):
try:
self.pool.put(conn, block=False)
except Full:
# This should never happen if self.block == True
log.warning("HttpConnectionPool is full, discarding connection: %s"
% self.host)
为什么这个异常在这里被捕获了?如果它被重新引发,我可以通过创建一个新会话并删除旧会话来在我的代码中处理此异常。
如果这只是一个警告,那么它是否意味着它不会以任何方式影响我的结果?我可以忽略它吗?如果不能,我该如何处理这种情况?
self.block
设置为True
了吗? - roippi:param block: If set to True, no more than **maxsize** connections will be used at a time. When no free connections are available, the call will block until a connection has been released.
- roippi