Change pool size after session init
FuturesSession does this, but it is lost since the HTTPAdapters are later replaced.
This commit is contained in:
parent
a1ccdc9d7a
commit
c4f221fba0
1 changed files with 7 additions and 3 deletions
|
|
@ -196,9 +196,13 @@ class Browser(object):
|
||||||
|
|
||||||
# defines a max_retries. It's mandatory in case a server is not
|
# defines a max_retries. It's mandatory in case a server is not
|
||||||
# handling keep alive correctly, like the proxy burp
|
# handling keep alive correctly, like the proxy burp
|
||||||
a = requests.adapters.HTTPAdapter(max_retries=self.MAX_RETRIES)
|
adapter_kwargs = dict(max_retries=self.MAX_RETRIES)
|
||||||
session.mount('http://', a)
|
# set connection pool size equal to MAX_WORKERS if needed
|
||||||
session.mount('https://', a)
|
if self.MAX_WORKERS > requests.adapters.DEFAULT_POOLSIZE:
|
||||||
|
adapter_kwargs.update(pool_connections=self.MAX_WORKERS,
|
||||||
|
pool_maxsize=self.MAX_WORKERS)
|
||||||
|
session.mount('https://', requests.adapters.HTTPAdapter(**adapter_kwargs))
|
||||||
|
session.mount('http://', requests.adapters.HTTPAdapter(**adapter_kwargs))
|
||||||
|
|
||||||
if self.TIMEOUT:
|
if self.TIMEOUT:
|
||||||
session.timeout = self.TIMEOUT
|
session.timeout = self.TIMEOUT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue