Skip to content

Commit 980e55e

Browse files
Check if config was async
1 parent b7b2b49 commit 980e55e

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

symphony/bdk/gen/api_client.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
""" # noqa: E501
1313

1414

15+
import asyncio
1516
import datetime
1617
from dateutil.parser import parse
1718
from enum import Enum
@@ -629,8 +630,22 @@ def update_params_for_auth(
629630
request_auth
630631
)
631632
else:
633+
auth_settings_callable = self.configuration.auth_settings
634+
# The auth_settings callable can be async, but this function is sync.
635+
# We need to run the coroutine to get the result. This is a workaround
636+
# for the generator producing mixed-style code.
637+
if asyncio.iscoroutinefunction(auth_settings_callable):
638+
try:
639+
loop = asyncio.get_running_loop()
640+
# This is a blocking call in an async context. It's not ideal, but it's
641+
# necessary here to contain the change to this file.
642+
auth_settings_dict = loop.run_until_complete(auth_settings_callable())
643+
except RuntimeError: # No running event loop
644+
auth_settings_dict = asyncio.run(auth_settings_callable())
645+
else:
646+
auth_settings_dict = auth_settings_callable()
632647
for auth in auth_settings:
633-
auth_setting = self.configuration.auth_settings().get(auth)
648+
auth_setting = auth_settings_dict.get(auth)
634649
if auth_setting:
635650
self._apply_auth_params(
636651
headers,

0 commit comments

Comments
 (0)