(
py: Python<'_>,
result: Py<PyAny>,
)
| 46 | type PyValueFuture = Pin<Box<dyn Future<Output = PyResult<Py<PyAny>>> + Send>>; |
| 47 | |
| 48 | fn split_json_or_future( |
| 49 | py: Python<'_>, |
| 50 | result: Py<PyAny>, |
| 51 | ) -> FlowResult<Result<Json, PyValueFuture>> { |
| 52 | let bound = result.bind(py); |
| 53 | if bound.getattr("__await__").is_ok() { |
| 54 | let future = pyo3_async_runtimes::tokio::into_future(result.into_bound(py)) |
| 55 | .map_err(|e| FlowError::Internal(e.to_string()))?; |
| 56 | Ok(Err(Box::pin(future) as PyValueFuture)) |
| 57 | } else { |
| 58 | let json = py_to_json(bound).map_err(|e: PyErr| FlowError::Internal(e.to_string()))?; |
| 59 | Ok(Ok(json)) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | async fn resolve_json_or_future( |
| 64 | outcome: FlowResult<Result<Json, PyValueFuture>>, |
no test coverage detected