MCPcopy Create free account
hub / github.com/YuminosukeSato/ironkernel / execute_callable_outcome

Function execute_callable_outcome

src/python/py_runtime.rs:55–91  ·  view source on GitHub ↗
(
    background: &CallableTask,
    callable: &Py<PyAny>,
    call_args: &Py<PyTuple>,
    call_kwargs: Option<&Py<PyDict>>,
    wants_delivery: bool,
)

Source from the content-addressed store, hash-verified

53}
54
55fn execute_callable_outcome(
56 background: &CallableTask,
57 callable: &Py<PyAny>,
58 call_args: &Py<PyTuple>,
59 call_kwargs: Option<&Py<PyDict>>,
60 wants_delivery: bool,
61) -> CallableOutcome {
62 Python::with_gil(|py| {
63 if background.is_done() {
64 return CallableOutcome::Cancelled;
65 }
66
67 let kwargs = call_kwargs.map(|value| value.bind(py));
68 let value = match callable.bind(py).call(call_args.bind(py), kwargs) {
69 Ok(value) => value,
70 Err(err) => return CallableOutcome::Failed(err.to_string()),
71 };
72
73 if background.is_done() {
74 return CallableOutcome::Cancelled;
75 }
76
77 let delivery_buffer = if wants_delivery {
78 match try_convert_to_buffer(value.as_any()) {
79 Ok(buffer) => Some(buffer),
80 Err(err) => return CallableOutcome::Failed(err.to_string()),
81 }
82 } else {
83 None
84 };
85
86 CallableOutcome::Ready {
87 value: value.unbind(),
88 delivery_buffer,
89 }
90 })
91}
92
93fn finalize_callable_outcome(
94 background: &CallableTask,

Callers 1

goMethod · 0.85

Calls 3

try_convert_to_bufferFunction · 0.85
is_doneMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected