def _run_finalizers(minpriority=None):
 if (minpriority is None):
  f = (lambda p: (p[0][0] is not None))
 else:
  f = (lambda p: ((p[0][0] is not None) and (p[0][0] >= minpriority)))
 items = [x for x in _finalizer_registry.items() if f(x)]
 items.sort(reverse=True)
 for (key, finalizer) in items:
  sub_debug('calling %s', finalizer)
  try:
   finalizer()
  except Exception:
   import traceback
   traceback.print_exc()
 if (minpriority is None):
  _finalizer_registry.clear()

def _run_finalizers ( minpriority = None ) : if ( minpriority is None ) : f = ( lambda p : ( p [ 0 ] [ 0 ] is not None ) ) else : f = ( lambda p : ( ( p [ 0 ] [ 0 ] is not None ) and ( p [ 0 ] [ 0 ] >= minpriority ) ) ) items = [ x for x in _finalizer_registry . items ( ) if f ( x ) ] items . sort ( reverse = True ) for ( key , finalizer ) in items : sub_debug ( 'calling %s' , finalizer ) try : finalizer ( ) except Exception : import traceback traceback . print_exc ( ) if ( minpriority is None ) : _finalizer_registry . clear ( )
run all finalizers whose exit priority is not none and at least minpriority finalizers with highest priority are called first; finalizers with the same priority will be called in reverse order of creation .