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
def all_packages(self): do(self)