当前位置: 首页>>代码示例>>Python>>正文


Python notifications.send_error_email函数代码示例

本文整理汇总了Python中notifications.send_error_email函数的典型用法代码示例。如果您正苦于以下问题:Python send_error_email函数的具体用法?Python send_error_email怎么用?Python send_error_email使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了send_error_email函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run_task

    def _run_task(self, task_id):
        task = self._scheduled_tasks[task_id]

        logger.info('[pid %s] Worker %s running   %s', os.getpid(), self._id, task_id)
        try:
            # Verify that all the tasks are fulfilled!
            ok = True
            for task_2 in task.deps():
                if not task_2.complete():
                    ok = False
                    missing_dep = task_2

            if not ok:
                # TODO: possibly try to re-add task again ad pending
                raise RuntimeError('Unfulfilled dependency %r at run time!\nPrevious tasks: %r' % (missing_dep.task_id, self._previous_tasks))
            task.run()
            error_message = json.dumps(task.on_success())
            logger.info('[pid %s] Worker %s done      %s', os.getpid(), self._id, task_id)
            task.trigger_event(Event.SUCCESS, task)
            status = DONE

        except KeyboardInterrupt:
            raise
        except Exception as ex:
            status = FAILED
            logger.exception("[pid %s] Worker %s failed    %s", os.getpid(), self._id, task)
            error_message = task.on_failure(ex)
            task.trigger_event(Event.FAILURE, task, ex)
            subject = "Luigi: %s FAILED" % task
            notifications.send_error_email(subject, error_message)

        self._scheduler.add_task(self._id, task_id, status=status,
                                  expl=error_message, runnable=None)

        return status
开发者ID:daveFNbuck,项目名称:luigi,代码行数:35,代码来源:worker.py

示例2: run

    def run(self):
        logger.info('[pid %s] Worker %s running   %s', os.getpid(), self.worker_id, self.task.task_id)

        if self.random_seed:
            # Need to have different random seeds if running in separate processes
            random.seed((os.getpid(), time.time()))

        try:
            # Verify that all the tasks are fulfilled!
            missing = [dep.task_id for dep in self.task.deps() if not dep.complete()]
            if missing:
                deps = 'dependency' if len(missing) == 1 else 'dependencies'
                raise RuntimeError('Unfulfilled %s at run time: %s' % (deps, ', '.join(missing)))
            self.task.trigger_event(Event.START, self.task)
            t0 = time.time()
            try:
                self.task.run()
            finally:
                self.task.trigger_event(Event.PROCESSING_TIME, self.task, time.time() - t0)
            error_message = json.dumps(self.task.on_success())
            logger.info('[pid %s] Worker %s done      %s', os.getpid(), self.worker_id, self.task.task_id)
            self.task.trigger_event(Event.SUCCESS, self.task)
            status = DONE

        except KeyboardInterrupt:
            raise
        except Exception as ex:
            status = FAILED
            logger.exception("[pid %s] Worker %s failed    %s", os.getpid(), self.worker_id, self.task)
            error_message = self.task.on_failure(ex)
            self.task.trigger_event(Event.FAILURE, self.task, ex)
            subject = "Luigi: %s FAILED" % self.task
            notifications.send_error_email(subject, error_message)

        self.result_queue.put((self.task.task_id, status, error_message, missing))
开发者ID:hwrdprkns,项目名称:luigi,代码行数:35,代码来源:worker.py

示例3: set_status

    def set_status(self, new_status, config):
        # not sure why we have SUSPENDED, as it can never be set
        if new_status == SUSPENDED:
            new_status = PENDING

        if new_status == DISABLED and self.status == RUNNING:
            return

        if self.status == DISABLED:
            if new_status == DONE:
                self.re_enable()

            # don't allow workers to override a scheduler disable
            elif self.scheduler_disable_time is not None:
                return

        if new_status == FAILED and self.can_disable():
            self.add_failure()
            if self.has_excessive_failures():
                self.scheduler_disable_time = time.time()
                new_status = DISABLED
                notifications.send_error_email(
                    'Luigi Scheduler: DISABLED {task} due to excessive failures'.format(task=self.id),
                    '{task} failed {failures} times in the last {window} seconds, so it is being '
                    'disabled for {persist} seconds'.format(
                        failures=config.disable_failures,
                        task=self.id,
                        window=config.disable_window,
                        persist=config.disable_persist,
                        ))
        elif new_status == DISABLED:
            self.scheduler_disable_time = None

        self.status = new_status
开发者ID:laurent-george,项目名称:luigi,代码行数:34,代码来源:scheduler.py

示例4: _email_complete_error

 def _email_complete_error(self, task, formatted_traceback):
     # like logger.exception but with WARNING level
     subject = "Luigi: {task} failed scheduling".format(task=task)
     message = "Will not schedule {task} or any dependencies due to error in complete() method:\n{traceback}".format(
         task=task, traceback=formatted_traceback
     )
     notifications.send_error_email(subject, message)
开发者ID:hualet,项目名称:luigi,代码行数:7,代码来源:worker.py

示例5: _run_task

    def _run_task(self, task_id):
        task = self._scheduled_tasks[task_id]

        logger.info('[pid %s] Worker %s running   %s', os.getpid(), self._id, task_id)
        try:
            # Verify that all the tasks are fulfilled!
            missing = [dep.task_id for dep in task.deps() if not dep.complete()]
            if missing:
                deps = 'dependency' if len(missing) == 1 else 'dependencies'
                # TODO: possibly try to re-add task again ad pending
                raise RuntimeError('Unfulfilled %s at run time: %s' % (deps, ', '.join(missing)))
            task.trigger_event(Event.START, task)
            task.run()
            error_message = json.dumps(task.on_success())
            logger.info('[pid %s] Worker %s done      %s', os.getpid(), self._id, task_id)
            task.trigger_event(Event.SUCCESS, task)
            status = DONE

        except KeyboardInterrupt:
            raise
        except Exception as ex:
            status = FAILED
            logger.exception("[pid %s] Worker %s failed    %s", os.getpid(), self._id, task)
            error_message = task.on_failure(ex)
            task.trigger_event(Event.FAILURE, task, ex)
            subject = "Luigi: %s FAILED" % task
            notifications.send_error_email(subject, error_message)

        self._scheduler.add_task(self._id, task_id, status=status,
                                  expl=error_message, runnable=None)

        self.run_succeeded &= status == DONE
        return status
开发者ID:ryanmartens,项目名称:luigi,代码行数:33,代码来源:worker.py

示例6: _run_task

    def _run_task(self, task_id):
        task = self._scheduled_tasks[task_id]

        logger.info('[pid %s] Worker %s running   %s', os.getpid(), self._id, task_id)
        try:
            # Verify that all the tasks are fulfilled!
            missing = [dep.task_id for dep in task.deps() if not dep.complete()]
            if missing:
                deps = 'dependency' if len(missing) == 1 else 'dependencies'
                raise RuntimeError('Unfulfilled %s at run time: %s' % (deps, ', '.join(missing)))
            task.trigger_event(Event.START, task)
            t0 = time.time()
            try:
                task.run()
            finally:
                task.trigger_event(Event.PROCESSING_TIME, task, time.time() - t0)
            error_message = json.dumps(task.on_success())
            logger.info('[pid %s] Worker %s done      %s', os.getpid(), self._id, task_id)
            task.trigger_event(Event.SUCCESS, task)
            status = DONE

        except KeyboardInterrupt:
            raise
        except Exception as ex:
            status = FAILED
            logger.exception("[pid %s] Worker %s failed    %s", os.getpid(), self._id, task)
            error_message = task.on_failure(ex)
            task.trigger_event(Event.FAILURE, task, ex)
            subject = "Luigi: %s FAILED" % task
            notifications.send_error_email(subject, error_message)

        self._scheduler.add_task(self._id, task_id, status=status,
                                 expl=error_message, runnable=None,
                                 params=task.to_str_params(),
                                 family=task.task_family)

        # re-add task to reschedule missing dependencies
        if missing:
            reschedule = True

            # keep out of infinite loops by not rescheduling too many times
            for task_id in missing:
                self.unfulfilled_counts[task_id] += 1
                if self.unfulfilled_counts[task_id] > self.__max_reschedules:
                    reschedule = False
            if reschedule:
                self.add(task)

        self.run_succeeded &= status == DONE
        return status
开发者ID:animeshinvinci,项目名称:luigi,代码行数:50,代码来源:worker.py

示例7: set_status

    def set_status(self, task, new_status):
        # not sure why we have SUSPENDED, as it can never be set
        if new_status == SUSPENDED:
            new_status = PENDING

        if new_status == DISABLED and task.status == RUNNING:
            return

        if task.status == DISABLED:
            if new_status == DISABLED:
                task.scheduler_disable_time = None
            elif new_status == DONE:
                task.re_enable()
                task.status = DONE
            elif task.scheduler_disable_time is None:
                # when it is disabled by client, we allow the status change
                task.status = new_status
            return

        if new_status == FAILED and task.can_disable():
            task.add_failure()
            if task.has_excessive_failures():
                task.scheduler_disable_time = datetime.datetime.now()
                new_status = DISABLED
                notifications.send_error_email(
                    'Luigi Scheduler: DISABLED {task} due to excessive failures'.format(task=task.id),
                    '{task} failed {failures} times in the last {window} seconds, so it is being '
                    'disabled for {persist} seconds'.format(
                        failures=self._disable_failures,
                        task=task.id,
                        window=self._disable_window,
                        persist=self._disable_persist,
                        ))
        elif new_status == DISABLED:
            task.scheduler_disable_time = None

        task.status = new_status
开发者ID:bearstech,项目名称:luigi,代码行数:37,代码来源:scheduler.py

示例8: _email_unexpected_error

 def _email_unexpected_error(self, task, formatted_traceback):
     subject = "Luigi: Framework error while scheduling {task}".format(task=task)
     message = "Luigi framework error:\n{traceback}".format(traceback=formatted_traceback)
     notifications.send_error_email(subject, message)
开发者ID:ChrisBg,项目名称:luigi,代码行数:4,代码来源:worker.py

示例9: run

    def run(self):
        logger.info('[pid %s] Worker %s running   %s', os.getpid(), self.worker_id, self.task.task_id)

        if self.random_seed:
            # Need to have different random seeds if running in separate processes
            random.seed((os.getpid(), time.time()))

        status = FAILED
        error_message = ''
        missing = []
        new_deps = []
        try:
            # Verify that all the tasks are fulfilled!
            missing = [dep.task_id for dep in self.task.deps() if not dep.complete()]
            if missing:
                deps = 'dependency' if len(missing) == 1 else 'dependencies'
                raise RuntimeError('Unfulfilled %s at run time: %s' % (deps, ', '.join(missing)))
            self.task.trigger_event(Event.START, self.task)
            t0 = time.time()
            status = None
            try:
                task_gen = self.task.run()
                if isinstance(task_gen, types.GeneratorType):  # new deps
                    next_send = None
                    while True:
                        try:
                            if next_send is None:
                                requires = task_gen.next()
                            else:
                                requires = task_gen.send(next_send)
                        except StopIteration:
                            break

                        new_req = flatten(requires)
                        status = (RUNNING if all(t.complete() for t in new_req)
                                  else SUSPENDED)
                        new_deps = [(t.task_family, t.to_str_params())
                                    for t in new_req]
                        if status == RUNNING:
                            self.result_queue.put(
                                (self.task.task_id, status, '', missing,
                                 new_deps))
                            next_send = getpaths(requires)
                        else:
                            logger.info(
                                '[pid %s] Worker %s new requirements      %s',
                                os.getpid(), self.worker_id, self.task.task_id)
                            return
            finally:
                if status != SUSPENDED:
                    self.task.trigger_event(
                        Event.PROCESSING_TIME, self.task, time.time() - t0)
            error_message = json.dumps(self.task.on_success())
            logger.info('[pid %s] Worker %s done      %s', os.getpid(),
                        self.worker_id, self.task.task_id)
            self.task.trigger_event(Event.SUCCESS, self.task)
            status = DONE

        except KeyboardInterrupt:
            raise
        except BaseException as ex:
            status = FAILED
            logger.exception("[pid %s] Worker %s failed    %s", os.getpid(), self.worker_id, self.task)
            error_message = notifications.wrap_traceback(self.task.on_failure(ex))
            self.task.trigger_event(Event.FAILURE, self.task, ex)
            subject = "Luigi: %s FAILED" % self.task
            notifications.send_error_email(subject, error_message)
        finally:
            self.result_queue.put(
                (self.task.task_id, status, error_message, missing, new_deps))
开发者ID:genba,项目名称:luigi,代码行数:70,代码来源:worker.py


注:本文中的notifications.send_error_email函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。