uranusjr commented on code in PR #68377:
URL: https://github.com/apache/airflow/pull/68377#discussion_r3458600169
##########
task-sdk/src/airflow/sdk/execution_time/comms.py:
##########
@@ -118,6 +122,39 @@
ReceiveMsgType = TypeVar("ReceiveMsgType", bound=BaseModel)
+class DeadlockImminentError(BaseException):
+ """
+ Raised when ``CommsDecoder.send()`` is called from the event loop thread.
+
+ Inherits from :class:`BaseException` rather than :class:`Exception` so that
+ ``contextlib.suppress(Exception)`` — used in
:func:`airflow.sdk.log.mask_secret`
+ and similar helpers — does **not** catch it. This ensures the error always
+ surfaces to the caller, pinpointing the incorrect use of a sync API from an
+ async context (e.g. ``BaseHook.get_hook()`` inside ``aexecute()``).
+
+ Fix: replace ``BaseHook.get_hook()`` with ``await BaseHook.aget_hook()``.
+ """
+
+ def __init__(self, msg: object, *, deadlock_imminent: bool) -> None:
+ import traceback
+
+ detail = (
+ "deadlock is imminent (asend() is concurrently in-flight)"
+ if deadlock_imminent
+ else "deadlock will occur as soon as another coroutine calls
asend()"
+ )
+ stack = "".join(traceback.format_stack())
Review Comment:
Is the traceback needed in the exception? There’s already a traceback when
the exception is raised. Is this a different stack?
--
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]