Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn on small con_pool_size during custom initalization of Updater #793

Merged
merged 1 commit into from Aug 12, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+16 −2
Diff settings

Always

Just for now

Copy path View file
@@ -95,8 +95,16 @@ def __init__(self,
if (token is not None) and (bot is not None):
raise ValueError('`token` and `bot` are mutually exclusive')

self.logger = logging.getLogger(__name__)

con_pool_size = workers + 4

if bot is not None:
self.bot = bot
if bot.request.con_pool_size < con_pool_size:
self.logger.warning(
'Connection pool of Request object is smaller than optimal value (%s)',
con_pool_size)
else:
# we need a connection pool the size of:
# * for each of the workers
@@ -107,7 +115,7 @@ def __init__(self,
if request_kwargs is None:
request_kwargs = {}
if 'con_pool_size' not in request_kwargs:
request_kwargs['con_pool_size'] = workers + 4
request_kwargs['con_pool_size'] = con_pool_size
self._request = Request(**request_kwargs)
self.bot = Bot(token, base_url, request=self._request)
self.user_sig_handler = user_sig_handler
@@ -121,7 +129,6 @@ def __init__(self,
workers=workers,
exception_event=self.__exception_event)
self.last_update_id = 0
self.logger = logging.getLogger(__name__)
self.running = False
self.is_idle = False
self.httpd = None
Copy path View file
@@ -86,6 +86,8 @@ def __init__(self,
sockopts.append((socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 30))
sockopts.append((socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 8))

self._con_pool_size = con_pool_size

kwargs = dict(
maxsize=con_pool_size,
cert_reqs='CERT_REQUIRED',
@@ -126,6 +128,11 @@ def __init__(self,

self._con_pool = mgr

@property
def con_pool_size(self):
"""The size of the connection pool used."""
return self._con_pool_size

def stop(self):
self._con_pool.clear()

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.