Exemplo n.º 1
0
 def handle_packet(self, pkg):
     def do_callback(tuple):
         logger.debug("Doing callback for %s", tuple)
         filter, callback = tuple
         if filter(pkg):
             try:
                 callback(pkg)
             except Exception as e:
                 logger.warn("Callback failed: %s : %s",
                         e.__class__.__name__, e)
         else:
             logger.debug("Rejected")
     logger.debug("Thread pool executing observer notify")
     with ThreadPoolExecutor(max_workers=3) as e:
         do(e.map(do_callback, self._observers.items()))
     return pkg
Exemplo n.º 2
0
    def handle_packet(self, pkg):
        def do_callback(tuple):
            logger.debug("Doing callback for %s", tuple)
            filter, callback = tuple
            if filter(pkg):
                try:
                    callback(pkg)
                except Exception as e:
                    logger.warn("Callback failed: %s : %s",
                                e.__class__.__name__, e)
            else:
                logger.debug("Rejected")

        logger.debug("Thread pool executing observer notify")
        with ThreadPoolExecutor(max_workers=3) as e:
            do(e.map(do_callback, self._observers.items()))
        return pkg
Exemplo n.º 3
0
 def all_packages(self):
     do(self)
Exemplo n.º 4
0
 def all_packages(self):
     do(self)