polymer/Polymer.py
def respawn_dead_workers(self):
        """Respawn workers / tasks upon crash"""
        for w_id, p in self.workers.items():
            if not p.is_alive():
                # Queue the task for another worker, if required...
                if self.log_level >= 2:
                    self.log.info("Worker w_id {0} died".format(w_id))
                task = self.worker_assignments.get(w_id, {})
                if self.log_level >= 2 and task != {}:
                    self.log.info(
                        "Dead worker w_id {0} was assigned task - {1}".format(
                            w_id, task
                        )
                    )
                error_suffix = ""
                if task != {}:
                    del self.worker_assignments[w_id]
                    if self.resubmit_on_error or self.hot_loop:
                        self.work_todo.append(task)
                        self.queue_task(task)
                        if self.log_level >= 2:
                            self.log.info("Resubmitting task - {0}".format(task))
                        error_suffix = " with task={1}".format(task)
                if self.log_level >= 1:
                    self.log.debug(
                        "TaskMgr.work_todo: {0} tasks left".format(len(self.work_todo))
                    )
                if self.log_level >= 2:
                    self.log.info(
                        "Respawning worker - w_id={0}{1}".format(w_id, error_suffix)
                    )
                self.workers[w_id] = Process(
                    target=Worker,
                    args=(w_id, self.t_q, self.r_q, self.worker_cycle_sleep),
                )
                self.workers[w_id].daemon = True
                self.workers[w_id].start()
def respawn_dead_workers(self):
        """Respawn workers / tasks upon crash"""
        for w_id, p in self.workers.items():
            if not p.is_alive():
                # Queue the task for another worker, if required...
                if self.log_level >= 2:
                    self.log.info("Worker w_id {0} died".format(w_id))
                task = self.worker_assignments.get(w_id, {})
                if self.log_level >= 2 and task != {}:
                    self.log.info(
                        "Dead worker w_id {0} was assigned task - {1}".format(
                            w_id, task
                        )
                    )
                error_suffix = ""
                if task != {}:
                    del self.worker_assignments[w_id]
                    if self.resubmit_on_error or self.hot_loop:
                        self.work_todo.append(task)
                        self.queue_task(task)
                        if self.log_level >= 2:
                            self.log.info("Resubmitting task - {0}".format(task))
                        error_suffix = " with task={1}".format(task)
                if self.log_level >= 1:
                    self.log.debug(
                        "TaskMgr.work_todo: {0} tasks left".format(len(self.work_todo))
                    )
                if self.log_level >= 2:
                    self.log.info(
                        "Respawning worker - w_id={0}{1}".format(w_id, error_suffix)
                    )
                self.workers[w_id] = Process(
                    target=Worker,
                    args=(w_id, self.t_q, self.r_q, self.worker_cycle_sleep),
                )
                self.workers[w_id].daemon = True
                self.workers[w_id].start()
def respawn_dead_workers ( self ) : for w_id , p in self . workers . items ( ) : if not p . is_alive ( ) : # Queue the task for another worker, if required... if self . log_level >= 2 : self . log . info ( "Worker w_id {0} died" . format ( w_id ) ) task = self . worker_assignments . get ( w_id , { } ) if self . log_level >= 2 and task != { } : self . log . info ( "Dead worker w_id {0} was assigned task - {1}" . format ( w_id , task ) ) error_suffix = "" if task != { } : del self . worker_assignments [ w_id ] if self . resubmit_on_error or self . hot_loop : self . work_todo . append ( task ) self . queue_task ( task ) if self . log_level >= 2 : self . log . info ( "Resubmitting task - {0}" . format ( task ) ) error_suffix = " with task={1}" . format ( task ) if self . log_level >= 1 : self . log . debug ( "TaskMgr.work_todo: {0} tasks left" . format ( len ( self . work_todo ) ) ) if self . log_level >= 2 : self . log . info ( "Respawning worker - w_id={0}{1}" . format ( w_id , error_suffix ) ) self . workers [ w_id ] = Process ( target = Worker , args = ( w_id , self . t_q , self . r_q , self . worker_cycle_sleep ) , ) self . workers [ w_id ] . daemon = True self . workers [ w_id ] . start ( )
Respawn workers / tasks upon crash
Respawn workers / tasks upon crash