Ejemplo n.º 1
0
 def performTask(self):
     from archivematicaMCP import limitGearmanConnectionsSemaphore
     limitGearmanConnectionsSemaphore.acquire()
     gm_client = gearman.GearmanClient([archivematicaMCP.config.get('MCPServer', "MCPArchivematicaServer")])
     data = {"createdDate" : datetime.datetime.now().__str__()}
     data["arguments"] = self.arguments
     print '"'+self.execute+'"', data
     completed_job_request = None
     failMaxSleep = 60
     failSleepInitial = 1
     failSleep = failSleepInitial
     failSleepIncrementor = 2
     while completed_job_request == None:
         try:
             completed_job_request = gm_client.submit_job(self.execute.lower(), cPickle.dumps(data), self.UUID)
         #raise ServerUnavailable('Found no valid connections: %r' % self.connection_list)
         #ServerUnavailable: Found no valid connections: [<GearmanConnection localhost:4730 connected=False>]
         except gearman.errors.ServerUnavailable as inst:
             completed_job_request = None
             time.sleep(failSleep)
             if failSleep == failSleepInitial:
                 print >>sys.stderr, inst.args
                 print >>sys.stderr, "Retrying issueing gearman command."
             if failSleep < failMaxSleep:
                 failSleep += failSleepIncrementor
     limitGearmanConnectionsSemaphore.release()
     self.check_request_status(completed_job_request)
     gm_client.shutdown()
     print "DEBUG: FINISHED PERFORMING TASK: ", self.UUID
Ejemplo n.º 2
0
 def performTask(self):
     from archivematicaMCP import limitGearmanConnectionsSemaphore
     limitGearmanConnectionsSemaphore.acquire()
     gm_client = gearman.GearmanClient([
         archivematicaMCP.config.get('MCPServer', "MCPArchivematicaServer")
     ])
     data = {"createdDate": timezone.now().isoformat(' ')}
     data["arguments"] = self.arguments
     LOGGER.info('Executing %s %s', self.execute, data)
     completed_job_request = None
     failMaxSleep = 60
     failSleepInitial = 1
     failSleep = failSleepInitial
     failSleepIncrementor = 2
     while completed_job_request == None:
         try:
             completed_job_request = gm_client.submit_job(
                 self.execute.lower(), cPickle.dumps(data), self.UUID)
         except gearman.errors.ServerUnavailable:
             completed_job_request = None
             time.sleep(failSleep)
             if failSleep == failSleepInitial:
                 LOGGER.exception('Error submitting job. Retrying.')
             if failSleep < failMaxSleep:
                 failSleep += failSleepIncrementor
     limitGearmanConnectionsSemaphore.release()
     self.check_request_status(completed_job_request)
     gm_client.shutdown()
     LOGGER.debug('Finished performing task %s', self.UUID)
Ejemplo n.º 3
0
 def performTask(self):
     from archivematicaMCP import limitGearmanConnectionsSemaphore
     limitGearmanConnectionsSemaphore.acquire()
     gm_client = gearman.GearmanClient([archivematicaMCP.config.get('MCPServer', "MCPArchivematicaServer")])
     data = {"createdDate" : datetime.datetime.now().__str__()}
     data["arguments"] = self.arguments
     print '"'+self.execute+'"', data
     completed_job_request = gm_client.submit_job(self.execute.lower(), cPickle.dumps(data), self.UUID)
     limitGearmanConnectionsSemaphore.release()
     self.check_request_status(completed_job_request)
     print "DEBUG: FINISHED PERFORMING TASK: ", self.UUID
     exit(0)