Module npsgd_worker :: Class NPSGDWorker
[hide private]
[frames] | no frames]

Class NPSGDWorker

source code

object --+
         |
        NPSGDWorker

Worker class for executing models and sending out result emails.

This enters a polling loop where the worker will poll the queue for tasks at a fixed interval. When it finds a task, it will decode it into a model, then process it using the model's "run" method.

Instance Methods [hide private]
 
__init__(self, serverAddress, serverPort)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
getServerInfo(self) source code
 
handleEvents(self)
Workhorse method of actually making requests to the queue for tasks.
source code
 
loop(self)
Main IO loop.
source code
 
notifyFailedTask(self, taskId) source code
 
notifySucceedTask(self, taskId) source code
 
processResponse(self, response) source code
 
processTask(self, taskDict)
Handle creation and running of a model and setup heartbeat thread.
source code
 
serverHasTask(self, taskId)
Method for ensuring that the queue still recognizes our task id.
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, serverAddress, serverPort)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

processTask(self, taskDict)

source code 

Handle creation and running of a model and setup heartbeat thread.

This is the heart of a worker. When we find a model on the queue, this method takes the request and decodes it into something that can be processed. It will then spawn a heartbeat thread that continues to check into the server while we actually enter the models "run" method. From there, it is all up to the model to handle.

serverHasTask(self, taskId)

source code 

Method for ensuring that the queue still recognizes our task id.

If the queue has expired the task for some reason (i.e. a timeout) this method will return false. Otherwise, it means we can proceed.