dstandish commented on code in PR #67877:
URL: https://github.com/apache/airflow/pull/67877#discussion_r3500309550


##########
task-sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -2065,6 +2065,43 @@ def _send_error_email_notification(
         log.exception("Failed to send email notification")
 
 
+@detail_span("task.execute")
+def _run_execute_callable(
+    context: Context,
+    execute: Callable[..., Any] | functools.partial[Any],
+    task: BaseOperator,
+) -> Any:
+    """
+    Run the task's execute callable, applying the execution timeout if one is 
set.
+
+    The contextvars snapshot is taken here, after the ``task.execute`` span is
+    current, so spans the operator emits during ``execute`` nest under it 
rather
+    than under the caller. ``ExecutorSafeguard``'s tracker is set into that 
copy
+    so the operator's ``execute`` passes the safeguard check, while the copy 
keeps
+    the change from leaking into the surrounding context.
+    """
+    ctx = contextvars.copy_context()

Review Comment:
   yeah this occurred to me -- it's a slight change but i think that it's 
arguably more correct to copy the context later. 



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