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

Method del

crates/stdlib/src/_asyncio.rs:785–827  ·  view source on GitHub ↗
(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

783
784 impl Destructor for PyFuture {
785 fn del(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<()> {
786 // Check if we should log the traceback
787 // Don't log if log_tb is false or if the future was cancelled
788 if !zelf.fut_log_tb.load(Ordering::Relaxed) {
789 return Ok(());
790 }
791
792 if zelf.fut_state.load() == FutureState::Cancelled {
793 return Ok(());
794 }
795
796 let exc = zelf.fut_exception.read().clone();
797 let exc = match exc {
798 Some(e) => e,
799 None => return Ok(()),
800 };
801
802 let loop_obj = zelf.fut_loop.read().clone();
803 let loop_obj = match loop_obj {
804 Some(l) => l,
805 None => return Ok(()),
806 };
807
808 // Create context dict for call_exception_handler
809 let context = PyDict::default().into_ref(&vm.ctx);
810 let class_name = zelf.class().name().to_string();
811 let message = format!("{} exception was never retrieved", class_name);
812 context.set_item(
813 vm.ctx.intern_str("message"),
814 vm.ctx.new_str(message).into(),
815 vm,
816 )?;
817 context.set_item(vm.ctx.intern_str("exception"), exc, vm)?;
818 context.set_item(vm.ctx.intern_str("future"), zelf.to_owned().into(), vm)?;
819
820 if let Some(tb) = zelf.fut_source_tb.read().clone() {
821 context.set_item(vm.ctx.intern_str("source_traceback"), tb, vm)?;
822 }
823
824 // Call loop.call_exception_handler(context)
825 let _ = vm.call_method(&loop_obj, "call_exception_handler", (context,));
826 Ok(())
827 }
828 }
829
830 impl Representable for PyFuture {

Callers

nothing calls this directly

Calls 14

to_stringMethod · 0.80
intern_strMethod · 0.80
loadMethod · 0.45
cloneMethod · 0.45
readMethod · 0.45
into_refMethod · 0.45
nameMethod · 0.45
classMethod · 0.45
set_itemMethod · 0.45
new_strMethod · 0.45
to_ownedMethod · 0.45
call_methodMethod · 0.45

Tested by

no test coverage detected