ashb commented on code in PR #55799:
URL: https://github.com/apache/airflow/pull/55799#discussion_r2356733846
##########
task-sdk/src/airflow/sdk/definitions/connection.py:
##########
@@ -203,6 +203,21 @@ def get(cls, conn_id: str) -> Any:
return _get_connection(conn_id)
except AirflowRuntimeError as e:
cls._handle_connection_error(e, conn_id)
+ except RuntimeError as e:
+ # The error from async_to_sync is a RuntimeError, so we have to
fall back to text matching
+ if str(e).startswith("You cannot use AsyncToSync in the same
thread as an async event loop"):
+ import warnings
+
+ import greenback
+
+ warnings.warn(
+ "You should not use sync calls here -- use `await
Conn.async_get` instead", stacklevel=2
+ )
+
+ return greenback.with_portal_run(cls.async_get, conn_id)
Review Comment:
This doesn't work:
```
[2025-09-17 20:38:37] WARNING - You should not use sync calls here -- use
`await Conn.async_get` instead category=UserWarning
[2025-09-17 20:38:37] INFO - Got it conn=<coroutine object with_portal_run
at 0xffff746cf240>
[2025-09-17 20:38:37] WARNING - coroutine 'with_portal_run' was never
awaited category=RuntimeWarning
```
--
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]