Exemplo n.º 1
0
 async def _listener_wrapper(self, key: str, func, *args, **kwargs):
     """
     Wraps a listener, ensuring ListenerExit is handled properly.
     """
     try:
         await func(*args, **kwargs)
     except ListenerExit:
         # remove the function
         self.temporary_listeners = remove_from_multidict(self.temporary_listeners, key, func)
     except Exception:
         logger.exception("Unhandled exception in listener {}!".format(func.__name__),
                          exc_info=True)
         self.temporary_listeners = remove_from_multidict(self.temporary_listeners, key, func)
Exemplo n.º 2
0
    def remove_listener_early(self, name: str, listener):
        """
        Removes a temporary listener early.

        :param name: The name of the event the listener is registered under.
        :param listener: The listener function.
        """
        self.event_listeners = remove_from_multidict(self.event_listeners, key=name, item=listener)
Exemplo n.º 3
0
    def remove_event(self, name: str, func):
        """
        Removes a function event.

        :param name: The name the event is registered under.
        :param func: The function to remove.
        """
        self.event_listeners = remove_from_multidict(self.event_listeners, key=name, item=func)