示例#1
0
文件: job.py 项目: sebleier/celery
    def on_failure(self, exc_info):
        """The handler used if the task raised an exception."""
        state.task_ready(self)

        if self.task.acks_late:
            self.acknowledge()

        self.send_event("task-failed", uuid=self.task_id,
                                       exception=repr(exc_info.exception),
                                       traceback=exc_info.traceback)

        context = {"hostname": self.hostname,
                   "id": self.task_id,
                   "name": self.task_name,
                   "exc": repr(exc_info.exception),
                   "traceback": unicode(exc_info.traceback, 'utf-8'),
                   "args": self.args,
                   "kwargs": self.kwargs}
        self.logger.error(self.error_msg.strip() % context)

        task_obj = tasks.get(self.task_name, object)
        send_error_email = conf.CELERY_SEND_TASK_ERROR_EMAILS and not \
                                task_obj.disable_error_emails and not any(
                                    isinstance(exc_info.exception, whexc)
                                    for whexc in
                                    conf.CELERY_TASK_ERROR_WHITELIST)
        if send_error_email:
            subject = self.email_subject.strip() % context
            body = self.email_body.strip() % context
            mail_admins(subject, body, fail_silently=True)
示例#2
0
    def waiting(self):
        """Is the taskset waiting?

        :returns: :const:`True` if any of the tasks in the taskset is still
            waiting for execution.

        """
        return any(not subtask.ready() for subtask in self.itersubtasks())
示例#3
0
文件: result.py 项目: frac/celery
    def waiting(self):
        """Is the taskset waiting?

        :returns: :const:`True` if any of the tasks in the taskset is still
            waiting for execution.

        """
        return any(not subtask.ready() for subtask in self.itersubtasks())
示例#4
0
    def failed(self):
        """Did the taskset fail?

        :returns: :const:`True` if any of the tasks in the taskset failed.
            (i.e., raised an exception)

        """
        return any(subtask.failed() for subtask in self.itersubtasks())
示例#5
0
文件: result.py 项目: frac/celery
    def failed(self):
        """Did the taskset fail?

        :returns: :const:`True` if any of the tasks in the taskset failed.
            (i.e., raised an exception)

        """
        return any(subtask.failed() for subtask in self.itersubtasks())
示例#6
0
文件: result.py 项目: kornholi/celery
    def waiting(self):
        """Are any of the tasks incomplete?

        :returns: :const:`True` if any of the tasks is still
            waiting for execution.

        """
        return any(not result.ready() for result in self.results)
示例#7
0
文件: result.py 项目: kornholi/celery
    def failed(self):
        """Did any of the tasks fail?

        :returns: :const:`True` if any of the tasks failed.
            (i.e., raised an exception)

        """
        return any(result.failed() for result in self.results)
示例#8
0
 def start(self, argv, cmd):
     self.splash()
     p = NamespacedOptionParser(argv)
     self.with_detacher_default_options(p)
     retcodes = []
     self.note("> Starting nodes...")
     for nodename, argv, _ in multi_args(p, cmd):
         self.note("\t> %s: " % (nodename, ), newline=False)
         retcode = self.waitexec(argv)
         self.note(retcode and self.FAILED or self.OK)
         retcodes.append(retcode)
     self.retcode = int(any(retcodes))
示例#9
0
 def start(self, argv, cmd):
     self.splash()
     p = NamespacedOptionParser(argv)
     self.with_detacher_default_options(p)
     retcodes = []
     self.note("> Starting nodes...")
     for nodename, argv, _ in multi_args(p, cmd):
         self.note("\t> %s: " % (nodename, ), newline=False)
         retcode = self.waitexec(argv)
         self.note(retcode and self.FAILED or self.OK)
         retcodes.append(retcode)
     self.retcode = int(any(retcodes))
示例#10
0
    def restart(self, argv, cmd):
        self.splash()
        p = NamespacedOptionParser(argv)
        self.with_detacher_default_options(p)
        retvals = []

        def on_node_shutdown(nodename, argv, pid):
            self.note(self.colored.blue("> Restarting node %s: " % nodename),
                      newline=False)
            retval = self.waitexec(argv)
            self.note(retval and self.FAILED or self.OK)
            retvals.append(retval)

        self._stop_nodes(p, cmd, retry=2, callback=on_node_shutdown)
        self.retval = int(any(retvals))
示例#11
0
    def restart(self, argv, cmd):
        self.splash()
        p = NamespacedOptionParser(argv)
        self.with_detacher_default_options(p)
        retvals = []

        def on_node_shutdown(nodename, argv, pid):
            self.note(self.colored.blue(
                "> Restarting node %s: " % nodename), newline=False)
            retval = self.waitexec(argv)
            self.note(retval and self.FAILED or self.OK)
            retvals.append(retval)

        self._stop_nodes(p, cmd, retry=2, callback=on_node_shutdown)
        self.retval = int(any(retvals))