def get_requests_session(self):
requests_session = self._session.GetParameter("requests_session")
if requests_session == None:
# To make sure we can use the requests session in the threadpool we
# need to make sure that the connection pool can block. Otherwise it
# will raise when it runs out of connections and the threads will be
# terminated.
requests_session = requests.Session()
requests_session.mount("https://", adapters.HTTPAdapter(
pool_connections=10, pool_maxsize=300, max_retries=10,
pool_block=True))
requests_session.mount("http://", adapters.HTTPAdapter(
pool_connections=10, pool_maxsize=300, max_retries=10,
pool_block=True))
self._session.SetCache("requests_session", requests_session)
return requests_session
评论列表
文章目录