@@ -342,6 +342,25 @@ def _signal_usr1(self, _signum: int, _frame: Any) -> None:
342342 def _signal_usr2 (self , _signum : int , _frame : Any ) -> None :
343343 self ._signal_snapshot ("signal_usr2" , trim = True )
344344
345+ def _record_inflight_trim_skip (self , phase : str , in_flight : int ) -> None :
346+ """Record why a trim was skipped without perturbing the live workload.
347+
348+ A full signal snapshot enumerates the Python heap. That work is
349+ specifically unhelpful while requests are in flight, and can hold the
350+ signal gate long enough to make a second operator signal look stuck.
351+ Preserve the bounded audit event while deliberately omitting sampled
352+ process details.
353+ """
354+ self ._append (
355+ {
356+ "ts_monotonic_ns" : time .monotonic_ns (),
357+ "phase" : f"{ phase } _skipped_in_flight" ,
358+ "sequence" : None ,
359+ "in_flight" : in_flight ,
360+ "trim" : {"attempted" : False , "reason" : "requests_in_flight" },
361+ }
362+ )
363+
345364 def _signal_snapshot (self , phase : str , * , trim : bool ) -> None :
346365 if not _enabled () or not self ._signal_lock .acquire (blocking = False ):
347366 return
@@ -351,7 +370,7 @@ def worker() -> None:
351370 with self ._lock :
352371 in_flight = self ._in_flight
353372 if trim and in_flight :
354- self .snapshot ( f" { phase } _skipped_in_flight" )
373+ self ._record_inflight_trim_skip ( phase , in_flight )
355374 return
356375 self .snapshot (f"{ phase } _before" )
357376 if trim :
0 commit comments