Package park :: Package core :: Module servicehandler :: Class ServiceHandler

Class ServiceHandler

source code


Process signals coming into and out of the service.

The service handler is running in a separate thread from the service itself. These are the service thread and the computation thread.

Progress messages are sent approximately every progress_delta seconds when the computation is in a ready state.

Checkpoint messages are sent approxmiately every checkpoint_delta seconds when the computation is in a ready state.

Improved messages are possibly sent when they are available, or possibly delayed until the computation is in a ready state.

Instance Methods
 
__init__(self, client=None, workers=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
onSignalMessage(self, msg)
If a handler is not found for processing the message asynchronously then queue the message until the system is in a ready state.
source code
 
onReadyMessage(self, msg)
If a handler is not found for processing the message synchronously then register a warning in the log.
source code
 
onSignalSet(self, msg)
Set handler attributes.
source code
 
onReadySet(self, msg)
Set service attribute.
source code
 
onReadyInvoke(self, msg)
Invoke method in the service.
source code
 
onSignalAbort(self, msg)
We received an abort signal.
source code
 
onSignalPause(self, msg)
We received a pause signal.
source code
 
onSignalResume(self, msg)
We received a resume signal.
source code
 
send(self, msg)
Send a message to the client(s).
source code
 
put(self, msg)
New message has arrived.
source code
 
delay(self, msg)
Delay the associated message until the compuation is in a ready state.
source code
 
start(self, service=None, request=None, resume=False)
Run a request through a service.
source code
 
improved(self, state)
Send an improvement message to the job listeners.
source code
 
ready(self)
Put the computation in a ready state.
source code
 
map(self, fn, request)
Return the [fn(x) for x in request]
source code
 
imap(self, fn, request, enumerated=False, ordered=True)
Return fn(x) for x in request in order as they are ready.
source code

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

Class Variables
  progress_delta = 1
Send progress updates every second
  checkpoint_delta = 3600
Store checkpoints every hour
  improved_delta = 0
Send improvement messages immediately
Instance Variables
  workers
parallel kernels
Properties

Inherited from object: __class__

Method Details

__init__(self, client=None, workers=None)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

onSignalMessage(self, msg)

source code 
If a handler is not found for processing the message asynchronously then queue the message until the system is in a ready state. The message will then be handled with an onReady handler.

onSignalSet(self, msg)

source code 

Set handler attributes.

Set the associated attributes in the service handler.

Forward any remaining attributes to the service when the computation is in a ready state.

onReadySet(self, msg)

source code 

Set service attribute.

Set the associated attributes in the service.

Raises AttributeError if there are unused attributes.

onSignalAbort(self, msg)

source code 
We received an abort signal. Cancel the computation when it is convenient. If the computation is paused resume it before handling the abort.

onSignalPause(self, msg)

source code 
We received a pause signal. Halt the computation at the next convenient point.

onSignalResume(self, msg)

source code 
We received a resume signal. Let the computation continue from the halted point.

put(self, msg)

source code 

New message has arrived.

Called from handler thread when new message has arrived.

For synchronous operations, this returns the result of the operation, otherwise this returns None.

start(self, service=None, request=None, resume=False)

source code 

Run a request through a service.

This function returns immediately and the request is processed in a separate thread.

Raises RuntimeError if a service is already running.

improved(self, state)

source code 

Send an improvement message to the job listeners.

Called from the computation thread when the results on the client should be updated.

ready(self)

source code 

Put the computation in a ready state.

Process external signals, update progress, set the checkpoint and .

Signals include pause, abort and resume, plus any signals that could not be handled synchronously.

Raises AbortService if the application is told to abort.

This method is run from the service thread.

imap(self, fn, request, enumerated=False, ordered=True)

source code 

Return fn(x) for x in request in order as they are ready.

If enumerated, returns (i,fn(x)) where i is the incoming order.

If ordered, returns fn(x) in the order they are completed.