Skip to content

Commit

Permalink
bit more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Dec 6, 2024
1 parent 91e5c64 commit c690661
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions openbb_platform/core/openbb_core/provider/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,25 @@ async def get_async_requests_session(**kwargs) -> ClientSession:
)

# SSL settings get passed to the TCPConnector used by the session.
connector = (
aiohttp.TCPConnector(ttl_dns_cache=300, **ssl_kwargs)
if ssl_kwargs
else kwargs.pop("connector", None)
connector = kwargs.pop("connector", None) or (
aiohttp.TCPConnector(ttl_dns_cache=300, **ssl_kwargs) if ssl_kwargs else None
)

conn_kwargs = {"connector": connector} if connector else {}

# Add basic auth for proxies and requests, if provided.
# Add basic auth for proxies, if provided.
if kwargs.get("proxy_auth"):
conn_kwargs["proxy_auth"] = aiohttp.BasicAuth(*kwargs.pop("proxy_auth", []))
p_auth = kwargs.pop("proxy_auth", [])
conn_kwargs["proxy_auth"] = aiohttp.BasicAuth(
*p_auth if isinstance(p_auth, (list, tuple)) else p_auth
)

# Add basic auth for the server connection, if provided.
if kwargs.get("auth"):
conn_kwargs["auth"] = aiohttp.BasicAuth(*kwargs.pop("auth", []))
s_auth = kwargs.pop("auth", [])
conn_kwargs["auth"] = aiohttp.BasicAuth(
*s_auth if isinstance(s_auth, (list, tuple)) else s_auth
)

if kwargs.get("cookies"):
_cookies = kwargs.pop("cookies", None)
Expand Down

0 comments on commit c690661

Please sign in to comment.