jscheffl commented on code in PR #65622:
URL: https://github.com/apache/airflow/pull/65622#discussion_r3170949467


##########
task-sdk/src/airflow/sdk/execution_time/comms.py:
##########
@@ -193,14 +194,36 @@ class CommsDecoder(Generic[ReceiveMsgType, SendMsgType]):
     # Async lock for async operations
     _async_lock: asyncio.Lock = attrs.field(factory=asyncio.Lock, repr=False)
 
+    @contextmanager
+    def _lock_sync(self):
+        """Acquire the thread lock for synchronous operations."""
+        with self._thread_lock:
+            yield
+
+    @asynccontextmanager
+    async def _lock_async(self):
+        """
+        Acquire both the async lock and the thread lock for asynchronous 
operations.
+
+        The thread lock is acquired via a thread executor so the event loop
+        is not blocked while waiting for other holders.
+        """
+        async with self._async_lock:
+            loop = asyncio.get_running_loop()
+            await loop.run_in_executor(None, self._thread_lock.acquire)

Review Comment:
   @uranusjr OK for you then? For me sounds reasonable.



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