@@ -68,7 +68,6 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
6868 # Added for proper async cleanup
6969 # This ensures spans are properly closed when using 'async with'
7070
71- # Added proper async cleanup
7271 if hasattr (self , "_agentops_active_span" ) and hasattr (self , "_agentops_span_context_manager" ):
7372 try :
7473 _record_entity_output (self ._agentops_active_span , self )
@@ -80,23 +79,6 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
8079 self ._agentops_span_context_manager = None
8180 self ._agentops_active_span = None
8281
83- def __del__ (self ):
84- # Only try to cleanup if we have valid span references
85- if (
86- hasattr (self , "_agentops_active_span" )
87- and hasattr (self , "_agentops_span_context_manager" )
88- and self ._agentops_span_context_manager is not None
89- and self ._agentops_active_span is not None
90- ):
91- try :
92- _record_entity_output (self ._agentops_active_span , self )
93- except Exception as e :
94- logger .warning (f"Failed to record entity output: { e } " )
95- self ._agentops_span_context_manager .__exit__ (None , None , None )
96- # Clear the span references after cleanup
97- self ._agentops_span_context_manager = None
98- self ._agentops_active_span = None
99-
10082 # Preserve metadata of the original class
10183 WrappedClass .__name__ = wrapped .__name__
10284 WrappedClass .__qualname__ = wrapped .__qualname__
0 commit comments