(
background: &CallableTask,
callable: &Py<PyAny>,
call_args: &Py<PyTuple>,
call_kwargs: Option<&Py<PyDict>>,
wants_delivery: bool,
)
| 53 | } |
| 54 | |
| 55 | fn 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 | |
| 93 | fn finalize_callable_outcome( |
| 94 | background: &CallableTask, |
no test coverage detected