def execute_safe(self, *args, **kwargs): try: return self.execute(*args, **kwargs) except Exception, exc: type_, value_, tb = sys.exc_info() exc = default_backend.prepare_exception(exc) warnings.warn("Exception happend outside of task body: %s: %s" % ( str(exc.__class__), str(exc))) return ExceptionInfo((type_, exc, tb))
def catch_exception(exception): try: raise exception except exception.__class__, exc: exc = default_backend.prepare_exception(exc) return exc, ExceptionInfo(sys.exc_info()).traceback