Skip to content

Commit

Permalink
Correction for unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemanja Martinovic committed Sep 3, 2022
1 parent 5f321f2 commit bc62ea3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion adsws/api/discoverer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ def __init__(self, endpoint, service_uri, deploy_path, route):
self.cs = None
try:
self.default_request_timeout = current_app.config.get("DEFAULT_REQUEST_TIMEOUT", 60)
self.pool_connections = current_app.config.get("REQUESTS_POOL_CONNECTIONS", 20)
self.pool_maxsize = current_app.config.get("REQUESTS_POOL_MAXSIZE", 1000)
self.max_retries = current_app.config.get("REQUESTS_MAX_RETRIES", 1)
except RuntimeError:
# Unit testing fails: "RuntimeError: Working outside of application context."
self.default_request_timeout = 60
self.pool_connections = 20
self.pool_maxsize = 1000
self.max_retries = 1
if service_uri.startswith('consul://'):
self.cs = ConsulService(
service_uri,
Expand All @@ -40,7 +46,10 @@ def __init__(self, endpoint, service_uri, deploy_path, route):
# requests sessions)
# http://docs.python-requests.org/en/latest/api/?highlight=max_retries#requests.adapters.HTTPAdapter
#
http_adapter = requests.adapters.HTTPAdapter(pool_connections=current_app.config.get("REQUESTS_POOL_CONNECTIONS", 20), pool_maxsize=current_app.config.get("REQUESTS_POOL_MAXSIZE", 1000), max_retries=current_app.config.get("REQUESTS_POOL_RETRIES", 1), pool_block=False)
http_adapter = requests.adapters.HTTPAdapter(pool_connections=self.pool_connections, \
pool_maxsize=self.pool_maxsize, \
max_retries=self.max_retries, \
pool_block=False)
self.session.mount('http://', http_adapter)

@staticmethod
Expand Down

0 comments on commit bc62ea3

Please sign in to comment.