From dc77a322970668a4ace5d52252792911862ed4e7 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Wed, 28 Aug 2024 06:39:11 -0700 Subject: [PATCH] add trust_env to ClientSession initialization to mimic proxy behaviour of requests library (#6640) Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> --- openbb_platform/core/openbb_core/provider/utils/helpers.py | 4 ++-- .../charting/openbb_charting/core/backend.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openbb_platform/core/openbb_core/provider/utils/helpers.py b/openbb_platform/core/openbb_core/provider/utils/helpers.py index 8ead2dc6e8e..d21aefd68a9 100644 --- a/openbb_platform/core/openbb_core/provider/utils/helpers.py +++ b/openbb_platform/core/openbb_core/provider/utils/helpers.py @@ -138,7 +138,7 @@ async def amake_request( ) with_session = kwargs.pop("with_session", "session" in kwargs) - session: ClientSession = kwargs.pop("session", ClientSession()) + session: ClientSession = kwargs.pop("session", ClientSession(trust_env=True)) try: response = await session.request(method, url, **kwargs) @@ -175,7 +175,7 @@ async def amake_requests( Union[dict, List[dict]] Response json """ - session: ClientSession = kwargs.pop("session", ClientSession()) + session: ClientSession = kwargs.pop("session", ClientSession(trust_env=True)) kwargs["response_callback"] = response_callback urls = urls if isinstance(urls, list) else [urls] diff --git a/openbb_platform/obbject_extensions/charting/openbb_charting/core/backend.py b/openbb_platform/obbject_extensions/charting/openbb_charting/core/backend.py index c21e34032e5..be07482f912 100644 --- a/openbb_platform/obbject_extensions/charting/openbb_charting/core/backend.py +++ b/openbb_platform/obbject_extensions/charting/openbb_charting/core/backend.py @@ -416,7 +416,7 @@ async def download_plotly_js(): # we use aiohttp to download plotly.js # this is so we don't have to block the main thread async with aiohttp.ClientSession( - connector=aiohttp.TCPConnector(verify_ssl=False) + connector=aiohttp.TCPConnector(verify_ssl=False), trust_env=True ) as session, session.get(f"https://cdn.plot.ly/{js_filename}") as resp: with open(str(PLOTLYJS_PATH), "wb") as f: while True: