(task: &PyObjectRef, fut: &PyObjectRef, vm: &VirtualMachine)
| 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 |
no test coverage detected