def cleanup_task(self, task_id): """Cleanup after the task. - kill child processes """ # clean up stray subtasks # self.logger.debug("cleanup_task: Trying to terminate task with SIGTERM: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) try: # success = kill_process_group(self.pid_dict[task_id]) success = kill_process_group(self.pid_dict[task_id], logger=self._logger) except IOError as ex: # proc file doesn"t exist -> process was already killed success = True if not success: # self.logger.debug("cleanup_task: Trying to terminate task with SIGKILL: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) try: # success = kill_process_group(self.pid_dict[task_id], signal.SIGKILL, timeout=2) success = kill_process_group(self.pid_dict[task_id], signal.SIGKILL, timeout=2, logger=self._logger) except IOError: # proc file doesn"t exist -> process was already killed success = True # if success: # self.logger.info("cleanup_task: Task terminated: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) # else: # self.logger.error("cleanup_task: Task NOT terminated: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) return success
def cleanup_task(self, task_id): """Cleanup after the task. Kill child processes.""" try: success = kill_process_group(self.pid_dict[task_id], logger=self._logger) except IOError as ex: # proc file doesn"t exist -> process was already killed success = True if not success: try: success = kill_process_group(self.pid_dict[task_id], signal.SIGKILL, timeout=2, logger=self._logger) except IOError: # proc file doesn"t exist -> process was already killed success = True return success
def cleanup_task(self, task_id): """Cleanup after the task. - kill child processes """ # clean up stray subtasks # self.logger.debug("cleanup_task: Trying to terminate task with SIGTERM: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) try: # success = kill_process_group(self.pid_dict[task_id]) success = kill_process_group(self.pid_dict[task_id], logger=self._logger) except IOError, ex: # proc file doesn"t exist -> process was already killed success = True
# clean up stray subtasks # self.logger.debug("cleanup_task: Trying to terminate task with SIGTERM: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) try: # success = kill_process_group(self.pid_dict[task_id]) success = kill_process_group(self.pid_dict[task_id], logger=self._logger) except IOError, ex: # proc file doesn"t exist -> process was already killed success = True if not success: # self.logger.debug("cleanup_task: Trying to terminate task with SIGKILL: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) try: # success = kill_process_group(self.pid_dict[task_id], signal.SIGKILL, timeout=2) success = kill_process_group(self.pid_dict[task_id], signal.SIGKILL, timeout=2, logger=self._logger) except IOError: # proc file doesn"t exist -> process was already killed success = True # if success: # self.logger.info("cleanup_task: Task terminated: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) # else: # self.logger.error("cleanup_task: Task NOT terminated: %s [#%s] (pid: %s)" % (self.task_dict[task_id]["method"], task_id, self.pid_dict[task_id])) return success def shutdown(self): """Terminate all tasks and exit.""" for task_id, task_info in self.task_dict.iteritems(): try: