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


##########
task-sdk/src/airflow/sdk/execution_time/context.py:
##########
@@ -142,8 +143,10 @@ def _get_connection(conn_id: str) -> Connection:
     from airflow.sdk.execution_time.comms import ErrorResponse, GetConnection
     from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
 
-    SUPERVISOR_COMMS.send_request(log=log, msg=GetConnection(conn_id=conn_id))
-    msg = SUPERVISOR_COMMS.get_message()
+    with SUPERVISOR_COMMS.lock:

Review Comment:
   It's probably worth adding a comment here saying why we need this
   ```suggestion
       # Since Triggers can hit this code path via `sync_to_async`  (which uses 
threads internally)
       # we need to make sure that we "atomically" send a request and get the 
response to that
       # back so that two triggers don't end up interleaving requests and end 
up with a possible
       # race condition where the wrong trigger reads the response.
       with SUPERVISOR_COMMS.lock:
   ```



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