mobuchowski commented on code in PR #68708:
URL: https://github.com/apache/airflow/pull/68708#discussion_r3501076465


##########
providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py:
##########
@@ -819,10 +820,49 @@ def _on_task_instance_manual_state_change(
 
     def _execute(self, callable, callable_name: str, use_fork: bool = False):
         if use_fork:
-            self._fork_execute(callable, callable_name)
+            if conf.execute_in_thread():
+                self._thread_execute(callable, callable_name)
+            else:
+                self._fork_execute(callable, callable_name)
         else:
             callable()
 
+    def _thread_execute(self, callable, callable_name: str):
+        """
+        Run OpenLineage event emission in a time-bounded daemon thread.
+
+        Opt-in alternative to :meth:`_fork_execute`, enabled via
+        ``[openlineage] execute_in_thread``. Unlike forking, this never 
duplicates the
+        task runner process, so no supervisor connection is inherited and left 
in a broken
+        state -- emission therefore cannot strand the task in the ``running`` 
state. The
+        task runner waits at most ``[openlineage] execution_timeout`` for 
emission and then
+        proceeds. Metadata extraction still runs in-process with full access 
to the task
+        runtime, so Operators whose extractors resolve Connections, Variables 
or XComs keep
+        working.
+        """
+        thread = threading.Thread(
+            target=callable,
+            name=f"openlineage-{callable_name}",
+            daemon=True,
+        )

Review Comment:
   @uranusjr fair; fixed that.



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