viirya commented on code in PR #7181:
URL: https://github.com/apache/datafusion-comet/pull/7181#discussion_r4369216569


##########
native/core/src/execution/python_udf.rs:
##########
@@ -600,6 +775,122 @@ mod tests {
         });
     }
 
+    fn running_calls(task_attempt_id: i64) -> Option<usize> {
+        tasks().get(&task_attempt_id).map(|task| task.calls.len())
+    }
+
+    #[test]
+    fn interrupts_running_call_of_killed_task() {
+        const TASK: i64 = -6811;
+        initialize_python().unwrap();
+        // `except Exception` must not swallow the interrupt.
+        let command = Python::attach(|py| {
+            cloudpickled_lambda(
+                py,
+                c"(lambda ns: (exec('def f(a):\\n    n = 0\\n    while 
True:\\n        n += 1\\n        try:\\n            n %= 7\\n        except 
Exception:\\n            pass\\n', ns), ns['f'])[1])({})",
+            )
+        });
+        let task = Arc::new(TaskRegistration::new(TASK));
+        let udf = Arc::new(
+            ArrowPythonUdf::from_command(&command, DataType::Int64, true, 
true, false, "")
+                .unwrap()
+                .with_task(Arc::clone(&task)),
+        );
+        let input: ArrayRef = Arc::new(Int64Array::from(vec![1]));
+        let (sender, receiver) = std::sync::mpsc::channel();
+        {
+            let (udf, input) = (Arc::clone(&udf), Arc::clone(&input));
+            // Not joined: a call that ignores the interrupt would never 
return.
+            std::thread::spawn(move || sender.send(udf.evaluate(&[input], 1)));

Review Comment:
   Fixed in 3d9fe9ec9. The worker drops its `Arc<ArrowPythonUdf>` before it 
sends the result, in a shared `start_call` helper that the interrupt tests now 
use.
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to