All pastes #443625 Raw Edit

Someone

public python v1 · immutable
·published 2007-04-16 22:05 UTC
rendered paste body
        for handler in handlers:            if handler == sentinel:                 #Todo: enyone has an idea how to avoid                 #going through handlers twice?                 #a dirty hack might be to search it by hand starting                 #from len(handlers) that should be faster for longer lists                break            guard, d = handler            if not callable(guard):                logger.info('bogus guard in handler for %s'%m)                continue            if guard(m):                done = True                if logger_messages.isEnabledFor(logging.DEBUG):                    logger.debug(                        "firing handler for %s: %s",                        _MSG_TYPE_DSCS[hdlr_type], m.getName())                try:                    d.callback(m)                    handlers.remove(handler)                except defer.AlreadyCalledError, e:                    logger.exception(                        "Message handled twice resulted in AlreadyCalledError. Swallowing.")                break        handlers.remove(sentinel)