def _wrapper(*args, **kwargs): try: return f(*args, **kwargs) except: exception.log_exception() if settings.DEBUG: return 'FAIL' else: return ''
def handle_message(self, sender, target, message): matched = None handler = None for h in self._handlers: matched = h.match(sender, message) if matched: handler = h break if not matched: rv = self.unknown(sender, message) return self.response_ok(rv) try: rv = handler.handle(sender, matched, message) return self.response_ok(rv) except exception.UserVisibleError, e: exception.log_exception() self.send_message([sender], str(e)) return self.response_error(e)
def process_view(self, request, callback, callback_args, callback_kwargs): if not settings.DEBUG: return # hotshot data if "_prof_heavy" in request.REQUEST: self.profiler = profile.Profile() args = (request,) + callback_args return self.profiler.runcall(callback, *args, **callback_kwargs) # output data for use in the profiling code if "_prof_db" in request.REQUEST or request.META.get("HTTP_X_PROFILE", "") == "db": self.prof_label = common_profile.label(request.path) # output data to be included on the page if "_prof_quick" in request.REQUEST: try: common_profile.install_api_profiling() except: exception.log_exception() self.prof_label = common_profile.label(request.path)
def process_view(self, request, callback, callback_args, callback_kwargs): if not settings.DEBUG: return # hotshot data if '_prof_heavy' in request.REQUEST: self.profiler = profile.Profile() args = (request, ) + callback_args return self.profiler.runcall(callback, *args, **callback_kwargs) # output data for use in the profiling code if ('_prof_db' in request.REQUEST or request.META.get('HTTP_X_PROFILE', '') == 'db'): self.prof_label = common_profile.label(request.path) # output data to be included on the page if '_prof_quick' in request.REQUEST: try: common_profile.install_api_profiling() except: exception.log_exception() self.prof_label = common_profile.label(request.path)
class Service(object): connection = None handlers = None _handlers = None def __init__(self, connection): self.connection = connection self._handlers = [] def init_handlers(self): if not self.handlers: return for handler_class in self.handlers: self._handlers.append(handler_class(self)) def handle_message(self, sender, target, message): matched = None handler = None for h in self._handlers: matched = h.match(sender, message) if matched: handler = h break if not matched: rv = self.unknown(sender, message) return self.response_ok(rv) try: rv = handler.handle(sender, matched, message) return self.response_ok(rv) except exception.UserVisibleError, e: exception.log_exception() self.send_message([sender], str(e)) return self.response_error(e) except exception.Error: exception.log_exception()