MCPcopy Index your code
hub / github.com/AI45Lab/Code / __anext__

Method __anext__

sdk/python/src/lib.rs:1000–1017  ·  view source on GitHub ↗

Returns an `asyncio.Future` that resolves to the next `AgentEvent`. Uses `run_in_executor` to bridge the blocking channel recv into an asyncio-compatible awaitable without requiring `pyo3-async`.

(&self, py: Python<'py>)

Source from the content-addressed store, hash-verified

998 /// Uses `run_in_executor` to bridge the blocking channel recv into an
999 /// asyncio-compatible awaitable without requiring `pyo3-async`.
1000 fn __anext__<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
1001 if self.done.load(Ordering::Relaxed) {
1002 return Err(PyStopAsyncIteration::new_err("stream exhausted"));
1003 }
1004
1005 let callable = Bound::new(
1006 py,
1007 BlockingRecv {
1008 rx: self.rx.clone(),
1009 done: self.done.clone(),
1010 },
1011 )?;
1012
1013 let asyncio = py.import("asyncio")?;
1014 let loop_ = asyncio.call_method0("get_running_loop")?;
1015 let future = loop_.call_method1("run_in_executor", (py.None(), callable))?;
1016 Ok(future)
1017 }
1018}
1019
1020// ============================================================================

Callers

nothing calls this directly

Calls 2

loadMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected