MCPcopy Create free account
hub / github.com/NVIDIA/NeMo-Relay / await_async_iter_value

Function await_async_iter_value

crates/python/src/py_callable.rs:119–139  ·  view source on GitHub ↗
(coro: Py<PyAny>)

Source from the content-addressed store, hash-verified

117}
118
119async fn await_async_iter_value(coro: Py<PyAny>) -> FlowResult<Option<Json>> {
120 let future = Python::attach(|py| {
121 pyo3_async_runtimes::tokio::into_future(coro.into_bound(py))
122 .map_err(|e| FlowError::Internal(e.to_string()))
123 })?;
124
125 match future.await {
126 Ok(result) => Python::attach(|py| {
127 py_to_json(result.bind(py))
128 .map(Some)
129 .map_err(|e| FlowError::Internal(e.to_string()))
130 }),
131 Err(error) => Python::attach(|py| {
132 if error.is_instance_of::<pyo3::exceptions::PyStopAsyncIteration>(py) {
133 Ok(None)
134 } else {
135 Err(FlowError::Internal(error.to_string()))
136 }
137 }),
138 }
139}
140
141async fn forward_async_iter(
142 async_iter: Arc<Py<PyAny>>,

Calls 1

py_to_jsonFunction · 0.85