Example #1
0
        def runTask():

            log.debug("Running task %s", task.task_id.value)
            startTime = time.time()
            sendUpdate(task, 'TASK_RUNNING', wallTime=0)

            # try to unpickle the task
            try:
                taskData = pickle.loads(decode_data(task.data))
            except:
                exc_info = sys.exc_info()
                log.error('Exception while unpickling task: ',
                          exc_info=exc_info)
                exc_type, exc_value, exc_trace = exc_info
                sendUpdate(task,
                           'TASK_FAILED',
                           wallTime=0,
                           msg=''.join(
                               traceback.format_exception_only(
                                   exc_type, exc_value)))
                return

            # This is where task.data is first invoked. Using this position to setup cleanupInfo
            if self.workerCleanupInfo is not None:
                assert self.workerCleanupInfo == taskData.workerCleanupInfo
            else:
                self.workerCleanupInfo = taskData.workerCleanupInfo

            # try to invoke a run on the unpickled task
            try:
                process = runJob(taskData)
                self.runningTasks[task.task_id.value] = process.pid
                try:
                    exitStatus = process.wait()
                    wallTime = time.time() - startTime
                    if 0 == exitStatus:
                        sendUpdate(task, 'TASK_FINISHED', wallTime)
                    elif -9 == exitStatus:
                        sendUpdate(task, 'TASK_KILLED', wallTime)
                    else:
                        sendUpdate(task,
                                   'TASK_FAILED',
                                   wallTime,
                                   msg=str(exitStatus))
                finally:
                    del self.runningTasks[task.task_id.value]
            except:
                wallTime = time.time() - startTime
                exc_info = sys.exc_info()
                log.error('Exception while running task:', exc_info=exc_info)
                exc_type, exc_value, exc_trace = exc_info
                sendUpdate(task,
                           'TASK_FAILED',
                           wallTime=wallTime,
                           msg=''.join(
                               traceback.format_exception_only(
                                   exc_type, exc_value)))

            wallTime = time.time() - startTime
            sendUpdate(task, 'TASK_FINISHED', wallTime)
Example #2
0
 def load(self, jobStoreID):
     try:
         jobString = self._readContents(jobStoreID)
     except NoSuchFileException:
         raise NoSuchJobException(jobStoreID)
     job = pickle.loads(jobString)
     # It is our responsibility to make sure that the JobDescription is
     # connected to the current config on this machine, for filling in
     # defaults. The leader and worker should never see config-less
     # JobDescriptions.
     job.assignConfig(self.config)
     return job
Example #3
0
 def load(self, jobStoreID):
     try:
         jobString = self._readContents(jobStoreID)
     except NoSuchFileException:
         raise NoSuchJobException(jobStoreID)
     return pickle.loads(jobString)  # UPDATE bz2.decompress(