def clear(self): """ Remove all registration listeners """ if not is_shutdown_requested(): with self.lock: del self.listeners[:] else: # when being in shutdown phase the lock might not be lockable # if a notify_added/removed is currently ongoing locked = self.lock.acquire(False) # remove all listeners anyway del self.listeners[:] if locked: self.lock.release()