Esempio n. 1
0
 def delete_worker(self, pseudo_index):
     """
     This actually deletes the worker :
     + Send SIGINT to the worker
     + Remove it from self.workers so that is is not restarted by
       manager cron
     """
     worker_dict = self.get_worker_dict(pseudo_index)
     if not worker_dict["busy"]:
         self._signal_process(worker_dict["worker"].pid, signal.SIGINT)
         del self.workers[pseudo_index - 1]
     else:
         raise InvalidWorkerReference("Worker with id %s is busy" %
                                      str(pseudo_index))
Esempio n. 2
0
 def get_worker_details(self, pseudo_index=None):
     if pseudo_index:
         try:
             temp_dict = dict(self.workers[pseudo_index - 1])
             temp_dict["worker"] = temp_dict["worker"].pid
             temp_dict["id"] = pseudo_index
             return (temp_dict)
         except IndexError:
             raise InvalidWorkerReference("No worker process with id: " +
                                          str(pseudo_index))
     else:
         worker_temp_list = []
         for i in range(0, len(self.workers)):
             temp_dict = dict(self.workers[i])
             temp_dict["worker"] = temp_dict["worker"].pid
             temp_dict["id"] = i + 1  # Zero-Index is not human friendly
             worker_temp_list.append(temp_dict)
         return (worker_temp_list)
Esempio n. 3
0
 def get_worker_details(self, pseudo_index=None):
     if pseudo_index:
         try:
             temp_dict = dict(self.workers[pseudo_index - 1])
             temp_dict["name"] = temp_dict["worker"].name
             temp_dict["worker"] = temp_dict["worker"].pid
             temp_dict["id"] = pseudo_index
             return temp_dict
         except IndexError:
             raise InvalidWorkerReference("No worker process with id: %s" %
                                          str(pseudo_index))
     else:
         worker_temp_list = []
         for i, obj in enumerate(self.workers):
             temp_dict = dict(self.workers[i])
             temp_dict["name"] = temp_dict["worker"].name
             temp_dict["worker"] = temp_dict["worker"].pid
             temp_dict["id"] = i + 1  # Zero-Index is not human friendly
             worker_temp_list.append(temp_dict)
         return worker_temp_list
Esempio n. 4
0
 def get_worker_dict(self, pseudo_index):
     try:
         return self.workers[pseudo_index - 1]
     except IndexError:
         raise InvalidWorkerReference("No worker process with id: %s" %
                                      str(pseudo_index))