ashb commented on code in PR #55799:
URL: https://github.com/apache/airflow/pull/55799#discussion_r2356843194


##########
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:
   This warning could be moved up to outside the has portal check 



-- 
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