Scientific.DistributedComputing.MasterSlave.MasterProcess

Package Scientific :: Package DistributedComputing :: Module MasterSlave :: Class MasterProcess |
[frames] | no frames]

# Class MasterProcess

    object --+
             |
            MasterProcess

Master process in a master-slave setup

A master process in a program is implemented by subclassing this class and overriding the method "run", which calls the methods "requestTask" and "retrieveResult". The process is then launched by calling the method "start".

Instance Methods
__init__(self, label, use_name_server=True) x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
deleteGlobalState(self, state_id) |
launchSlaveJobs(self, n=1) Launch n slave jobs on the machine that also runs the master job. |
`str` |
requestTask(self, tag, *parameters) Launches a task request. |
`tuple` |
retrieveResult(self, tag=None) Returns: a tuple containing three values: the task id to which the result corresponds, the tag of the computational task, and the result returned by the slave method that handled the task |
run(self) The main routine of the master process. |
setGlobalState(self, **kw) |
shutdown(self) |
start(self) Starts the master process. |
taskManagerThread(self) This method represents the code that is executed in a background thread for remote access to the task manager. |
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, label, use_name_server=True) (Constructor) |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Parameters: `label` (`str`) - the label that identifies the task manager `use_name_server` (`bool`) - If `True` (default), the task manager is registered with the Pyro name server. If `False`, the name server is not used and slave processes need to know the host on which the master process is running. Overrides: object.__init__

### launchSlaveJobs(self, n=1) |
Launch n slave jobs on the machine that also runs the master job. Parameters: `n` (`int`) - the number of slave jobs to be launched.

### requestTask(self, tag, *parameters) |
Launches a task request. The task will be executed by a slave process in a method called "do_"+tag that is called with the parameters given in the task request. Note that the order of task executions is not defined. Parameters: `tag` (`str`) - a tag identifying the computational task. It corresponds to the name of a method in the slave process. `parameters` - the parameters passed to the corresponding method in the slave process. The only restriction on their types is that all parameters must be picklable. Returns: `str` a unique task id

### retrieveResult(self, tag=None) |
Parameters: `tag` (`str`) - a tag identifying the computational task from which a return value is requested. If `None`, results from any task will be accepted. Returns: `tuple` a tuple containing three values: the task id to which the result corresponds, the tag of the computational task, and the result returned by the slave method that handled the task Raises: `TaskRaisedException` - if the slave method raised an exception

### run(self) |
The main routine of the master process. This method must be overridden in subclasses.