Esempio n. 1
0
 def start(self):
     with acquired_lock(self._runner_lock):
         self.process = Popen(self.command_sequence,
                              stdin=self.stdin,
                              stdout=self.stdout,
                              stderr=self.stderr,
                              env=self.environment,
                              cwd=self.working_directory)
     return self.process
Esempio n. 2
0
 def start(self):
     with acquired_lock(self._runner_lock):
         self.process = Popen(
             self.command_sequence,
             stdin=self.stdin,
             stdout=self.stdout,
             stderr=self.stderr,
             env=self.environment,
             cwd=self.working_directory
         )
     return self.process
Esempio n. 3
0
 def run(self, force_rerun=False, lock=None):
     """
     """
     #TODO figure out if the lock is even necessary.  There should be at worst a 1-to-1 mapping between threads and Computation instances
     if lock is None:
         # Just create a dummy lock
         lock = threading.Lock()
     with acquired_lock(lock):
         already_run = self.already_run()
         completed = self.completed
         runner = self.runner
     if not force_rerun and already_run:
         with acquired_lock(lock):
             if show_warnings:
                 warn(
                     "Using already-run version of calculation in directory {0} since"
                     " generated input would be identical to the one already existing"
                     " and output appears to have completed successfully.  To force"
                     " rerun, set the 'force_rerun' argument of 'Computation.run()'"
                     " to True.".format(self.directory)
                 )
             self.started = True
             self.completed = True
             self.__output_check()
     elif not completed or force_rerun:
         with acquired_lock(lock):
             self.__input_check()
             self.started = True
         runner.run()
         with acquired_lock(lock):
             self.completed = True
             self.__output_check()
     else:
         with acquired_lock(lock):
             if show_warnings:
                 warn("calculation already ran and will not be rerun.  To force rerun, set the 'force_rerun' argument of `Computation.run()` to True")
     return runner