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

Method __call__

sdk/python/src/lib.rs:910–934  ·  view source on GitHub ↗
(&self, py: Python<'_>)

Source from the content-addressed store, hash-verified

908#[pymethods]
909impl BlockingRecv {
910 fn __call__(&self, py: Python<'_>) -> PyResult<PyAgentEvent> {
911 let rx = self.rx.clone();
912 let done_flag = self.done.clone();
913 let result = py.allow_threads(|| {
914 get_runtime().block_on(async {
915 let mut guard = rx.lock().await;
916 guard.recv().await
917 })
918 });
919 match result {
920 Some(event) => {
921 let is_end = matches!(event, RustAgentEvent::End { .. });
922 let is_error = matches!(event, RustAgentEvent::Error { .. });
923 let py_event = PyAgentEvent::from(event);
924 if is_end || is_error {
925 done_flag.store(true, Ordering::Relaxed);
926 }
927 Ok(py_event)
928 }
929 None => {
930 done_flag.store(true, Ordering::Relaxed);
931 Err(PyStopAsyncIteration::new_err("stream exhausted"))
932 }
933 }
934 }
935}
936
937/// Iterator / async-iterator that yields AgentEvents from a streaming execution.

Callers

nothing calls this directly

Calls 4

block_onMethod · 0.80
storeMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected