Ejemplo n.º 1
0
 def submit_async(self, *args):
     # If run_parallel == True, works the same as the submit() method
     # If run_parallel == False, then the job will be run asynchronously in a job_runner
     # thread.
     # TODO: The submit() method must be deprecated and replaced with this method after we
     # make sure no code depends on submit() synchronous behavior. So every job submitted
     # will run asynchronously no matter run_parallel value and no different running semantics
     # will be used.
     if self.run_parallel:
         job = self.cluster.submit(*args)
         self.jobs.append(job)
     else:
         # dispy will a sign a job.id automatically
         job = dispy.DispyJob(None, args, ())
         self.job_runner_inbox.put((1, job, args))
     return job
Ejemplo n.º 2
0
 def submit(self, *args):
     """
     function to submit jobs to dispy. If run_parallel == False, the jobs are executed
     :param args:
     :return:
     """
     if self.run_parallel:
         self.jobs.append(self.cluster.submit(*args))
     # if no-parallel was invoked, execute the procedure manually and synchronously
     elif not self.callback:
         self.function(*args)
     else:
         job = dispy.DispyJob(None, args, ())
         try:
             job.result = self.function(*args)
             if self.progress_bar is not None:
                 self.progress_bar.update()
         except Exception as e:
             job.exception = e
         self.callback(job)