Programmer-RD-AI commented on code in PR #55812:
URL: https://github.com/apache/airflow/pull/55812#discussion_r2358330003


##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -172,13 +172,33 @@ def _get_connection(conn_id: str) -> Connection:
 
 
 async def _async_get_connection(conn_id: str) -> Connection:
-    # TODO: add async support for secrets backends
+    from asgiref.sync import sync_to_async
 
     from airflow.sdk.execution_time.comms import GetConnection
+    from airflow.sdk.execution_time.supervisor import 
ensure_secrets_backend_loaded
     from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
 
-    msg = await SUPERVISOR_COMMS.asend(GetConnection(conn_id=conn_id))
+    # TODO: check cache first
+    # enabled only if SecretCache.init() has been called first
 
+    # Try secrets backends first using async wrapper
+    backends = ensure_secrets_backend_loaded()
+    for secrets_backend in backends:
+        try:
+            conn = await sync_to_async(secrets_backend.get_connection)(conn_id)

Review Comment:
   maybe just pull `sync_to_async(secrets_backend.get_connection)` up once and 
reuse it? feels a bit cleaner than wrapping it every loop



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to