uranusjr commented on code in PR #68377:
URL: https://github.com/apache/airflow/pull/68377#discussion_r3509783084
##########
task-sdk/src/airflow/sdk/execution_time/comms.py:
##########
@@ -118,6 +123,42 @@
ReceiveMsgType = TypeVar("ReceiveMsgType", bound=BaseModel)
+class DeadlockImminentError(BaseException):
+ """
+ Raised when ``CommsDecoder.send()`` is called from the event loop thread
while
+ ``_thread_lock`` is already held by a concurrent ``asend()`` round-trip.
+
+ The sync ``send()`` attempts a non-blocking lock acquire when it detects
it is
+ running on the event loop thread. If the acquire fails — meaning an
``asend()``
+ coroutine currently owns the lock and is waiting for the event loop to
complete
+ its I/O — a true deadlock would result, so this error is raised instead.
+
+ 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()``.
Review Comment:
Please review these strings… “Fix” makes no sense here once this PR is
merged.
--
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]