| 552 | } |
| 553 | |
| 554 | fn call_soon_with_context( |
| 555 | zelf: &PyRef<Self>, |
| 556 | callback: PyObjectRef, |
| 557 | context: Option<PyObjectRef>, |
| 558 | vm: &VirtualMachine, |
| 559 | ) -> PyResult<()> { |
| 560 | let loop_obj = zelf.fut_loop.read().clone(); |
| 561 | if let Some(loop_obj) = loop_obj { |
| 562 | // call_soon(callback, *args, context=context) |
| 563 | // callback receives the future as its argument |
| 564 | let future_arg: PyObjectRef = zelf.clone().into(); |
| 565 | let args = if let Some(ctx) = context { |
| 566 | FuncArgs::new( |
| 567 | vec![callback, future_arg], |
| 568 | KwArgs::new([("context".to_owned(), ctx)].into_iter().collect()), |
| 569 | ) |
| 570 | } else { |
| 571 | FuncArgs::new(vec![callback, future_arg], KwArgs::default()) |
| 572 | }; |
| 573 | vm.call_method(&loop_obj, "call_soon", args)?; |
| 574 | } |
| 575 | Ok(()) |
| 576 | } |
| 577 | |
| 578 | // Properties |
| 579 | #[pygetset] |