Package multi :: Module slave_commands :: Class Slave_command
[hide private]
[frames] | no frames]

Class Slave_command

source code


A command to executed remotely on the slave processor - designed to be subclassed by users.

The command should be queued with the command queue using the add_to_queue command of the master and must return at least one Result_command even if it is a processor.NULL_RESULT. Results are returned from the Slave_command to the master processor using the return_object method of the processor passed to the command. Any exceptions raised will be caught wrapped and returned to the master processor by the slave processor.


Note: Good examples of subclassing a slave command include multi.commands.MF_minimise_command and multi.commands.Get_name_command.

See Also:
multi.commands.MF_minimise_command., multi.commands.Get_name_command.
Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
run(self, processor, completed)
Run the slave command on the slave processor
source code
 
set_memo_id(self, memo)
Called by the master processor to remember this Slave_commands memo.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

run(self, processor, completed)

source code 

Run the slave command on the slave processor

This is a base method which must be overridden.

The run command must return at least one Result_command even if it is a processor.NULL_RESULT. Results are returned from the Slave_command to the master processor using the return_object method of the processor passed to the command. Any exceptions raised will be caught wrapped and returned to the master processor by the slave processor.

Parameters:
  • processor (Processor instance) - The slave processor the command is running on. Results from the command are returned via calls to processor.return_object.
  • completed (bool) - The flag used in batching result returns to indicate that the sequence of batched result commands has completed. This value should be returned via the last result object retuned by this method or methods it calls. All other Result_commands should be initialised with completed=False. This is an optimisation to prevent the sending an extra batched result queue completion result command being sent, it may be an over early optimisation.

set_memo_id(self, memo)

source code 

Called by the master processor to remember this Slave_commands memo.

Parameters:
  • memo - The memo to remember, memos are remembered by getting the memo_id of the memo.