MCPcopy Index your code
hub / github.com/RustPython/RustPython / task_wakeup_impl

Function task_wakeup_impl

crates/stdlib/src/_asyncio.rs:2285–2306  ·  view source on GitHub ↗
(task: &PyObjectRef, fut: &PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2283 }
2284
2285 fn task_wakeup_impl(task: &PyObjectRef, fut: &PyObjectRef, vm: &VirtualMachine) -> PyResult {
2286 let task_ref: PyRef<PyTask> = task
2287 .clone()
2288 .downcast()
2289 .map_err(|_| vm.new_type_error("task_wakeup called with non-Task object"))?;
2290
2291 // Remove awaited_by relationship before resuming
2292 future_discard_from_awaited_by(fut.clone(), task.clone(), vm)?;
2293
2294 *task_ref.task_fut_waiter.write() = None;
2295
2296 // Call result() on the awaited future to get either result or exception
2297 // If result() raises an exception (like CancelledError), pass it to task_step
2298 let exc = match vm.call_method(fut, "result", ()) {
2299 Ok(_) => None,
2300 Err(e) => Some(e.into()),
2301 };
2302
2303 // Call task_step directly instead of using call_soon
2304 // This allows the awaiting task to continue in the same event loop iteration
2305 task_step_impl(task, exc, vm)
2306 }
2307
2308 // Module Functions
2309

Callers 1

callMethod · 0.85

Calls 7

task_step_implFunction · 0.85
downcastMethod · 0.80
SomeClass · 0.50
cloneMethod · 0.45
writeMethod · 0.45
call_methodMethod · 0.45

Tested by

no test coverage detected