def keep_alive(self):
        """
        Prevent immediate Broker shutdown while deferred functions remain.
        """
        self._lock.acquire()
        try:
            return len(self._deferred)
        finally:
            self._lock.release()
def keep_alive ( self ) : self . _lock . acquire ( ) try : return len ( self . _deferred ) finally : self . _lock . release ( )
Prevent immediate Broker shutdown while deferred functions remain.