MCPcopy Create free account
hub / github.com/AI45Lab/Code / complete_external_task

Method complete_external_task

sdk/python/src/lib.rs:2357–2383  ·  view source on GitHub ↗
(
        &self,
        py: Python<'_>,
        task_id: String,
        success: bool,
        result: Option<&Bound<'_, PyDict>>,
        error: Option<String>,
    )

Source from the content-addressed store, hash-verified

2355 /// True if the task was found and completed, False if not found.
2356 #[pyo3(signature = (task_id, success=true, result=None, error=None))]
2357 fn complete_external_task(
2358 &self,
2359 py: Python<'_>,
2360 task_id: String,
2361 success: bool,
2362 result: Option<&Bound<'_, PyDict>>,
2363 error: Option<String>,
2364 ) -> PyResult<bool> {
2365 let result_value = match result {
2366 Some(dict) => {
2367 let json_str = py_dict_to_json(dict)?;
2368 serde_json::from_str(&json_str)
2369 .map_err(|e| PyValueError::new_err(format!("Invalid JSON: {e}")))?
2370 }
2371 None => serde_json::json!({}),
2372 };
2373 let ext_result = RustExternalTaskResult {
2374 success,
2375 result: result_value,
2376 error,
2377 };
2378 let session = self.inner.clone();
2379 let found = py.allow_threads(move || {
2380 get_runtime().block_on(session.complete_external_task(&task_id, ext_result))
2381 });
2382 Ok(found)
2383 }
2384
2385 /// Get pending external queue tasks.
2386 ///

Callers

nothing calls this directly

Calls 4

py_dict_to_jsonFunction · 0.85
block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected