Пример #1
0
 def dequeue(self, job: Job, worker: Worker):
     """
     Start working on a given job
     :param job: the job to start
     :param worker: the worker to assign to
     @raises NoResponseFromWorkerException if the connection fails
     """
     job.set_status('ACTIVE')
     priority = job.priority
     job.set_priority(None)
     result = self._master_communicator.assign_task(job, worker)
     if 'Exception' in result and result['Exception'] != 'None':
         if result['Exception'] == 'WorkerStatusException':
             worker.set_status(
                 self._master_communicator.get_status(worker)['status'])
             if worker.get_status() == 'WAITING':
                 self.dequeue(job, worker)
             else:
                 job.set_status('QUEUED')
                 job.set_priority(priority)
                 usable = Worker.get_idle_workers_for_storages(
                     job.source_alias, job.target_alias)
                 if usable:
                     self.dequeue(job, usable[0])
         elif result['Exception'] == 'NamingConventionError':
             job.set_error(
                 'NamingConventionError: The source file has a Filename that does not fit the Convention'
             )
             job.set_status('CANCELED')
             notification_handler.resolve_notification(job)
Пример #2
0
def test_error_job():
    try:
        user = User.get_user_by_username("uyefv")
    except UserNotFoundException:
        user = User("uyefv", "token")
    job = Job('storageA', 'storageB', '~/.data/', [False, False, False], user)
    job.set_error("Target not mounted")
    job.set_status(JobStatus.PAUSED)
    notification_handler.resolve_notification(job)