def __init__( self, stellar_evolution_class, number_of_workers=1, individual_options=None, **options ): OptionalAttributes.__init__(self, **options) self.code_factory = stellar_evolution_class self.number_of_workers = number_of_workers self.model_time = 0.0 | units.Myr if individual_options is None: options_list = [options] * number_of_workers else: options_list = [options.copy() for i in range(number_of_workers)] for individual, shared in zip(individual_options, options_list): shared.update(individual) threads = [ThreadWithResult(target=stellar_evolution_class, kwargs=options_list[i]) for i in range(number_of_workers)] self.code_instances = self._execute_all_threads(threads) self.particles = ParallelParticlesSuperset( [code.particles for code in self.code_instances], execute_all_threads_func=self._execute_all_threads) self.parameters = ParallelParameters(self.code_instances)
def __init__(self, name_of_the_worker='worker_code', **options): """ Instantiates an object, starting the worker. Deleting the instance, with ``del``, will stop the worker. The worker can be started with a gdb session. The code will start gdb in a new xterm window. To enable this debugging support, the ``DISPLAY`` environment variable must be set and the X display must be accessable, ``xhost +``. :argument name_of_the_worker: The filename of the application to start :argument number_of_workers: Number of applications to start. The application must have parallel MPI support if this is more than 1. :argument debug_with_gdb: Start the worker(s) in a gdb session in a separate xterm :argument hostname: Start the worker on the node with this name """ OptionalAttributes.__init__(self, **options) self.instances.append(weakref.ref(self)) # #ave: no more redirection in the code #1) does not seem to work in fortran correctly #2) seems to break on hydra # #if not 'debugger' in options: # self._redirect_outputs(*self.redirection_filenames) # if self.must_start_worker: self._start(name_of_the_worker=name_of_the_worker, **options)
def __init__(self, interface, **options): OptionalAttributes.__init__(self, **options) self.states = {} self._do_automatic_state_transitions = True self._current_state = State(self, None) self.interface = interface self._initial_state = None