dstandish commented on code in PR #55799:
URL: https://github.com/apache/airflow/pull/55799#discussion_r2356849468
##########
task-sdk/src/airflow/sdk/definitions/connection.py:
##########
@@ -203,6 +204,24 @@ 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 greenback
+
+ task = asyncio.current_task()
+ if greenback.has_portal(task):
+ import warnings
+
+ warnings.warn(
+ "You should not use sync calls here -- use `await
Conn.async_get` instead",
+ stacklevel=2,
+ )
Review Comment:
i thought of that but if we don't have a portal, it will hit this code path
```
log.exception("async_to_sync failed")
raise
```
so i figured the existing exception logging and failure is good enough
we only really need to warn if we're _not_ going to fail, i think
--
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]