Package papyros :: Class Master
[hide private]
[frames] | no frames]

Class Master

source code

object --+
         |
        Master
Known Subclasses:
multithreaded.MultiThreadedMaster, distributed.DistributedMaster, singlethreaded.SingleThreadedMaster

A Job dispatcher object, controlling a set of slaves.

Instance Methods [hide private]
 
__init__(self, input_size=0, output_size=0)
Initialize this master.
source code
 
addJob(self, job, timeout=None)
Add a Job to the input queue.
source code
 
cancelAllJobs(self)
Cancel all unassigned jobs.
source code
 
numPendingJobs(self)
Return the approximate number of pending (waiting or in progress) jobs.
source code
 
popProcessedJob(self, timeout=None)
Pop the next processed Job from the output queue.
source code
 
processedJobs(self, timeout=None)
Return a list of processed jobs.
source code
 
_assignJob(self, poll_time=10)
Pop the next unassigned non-cancelled job.
source code
 
_getProcessedJob(self, job)
Add a processed job in the output queue.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, input_size=0, output_size=0)
(Constructor)

source code 
Initialize this master.
Parameters:
  • input_size - If a positive integer, it's the maximum number of unassigned jobs. Trying to add a new Job when the queue is full blocks or raises Queue.Full exception.
  • output_size - If a positive integer, it's the maximum number of completed jobs waiting to be fetched. No more jobs are assigned to the slaves when this number is reached.
Overrides: object.__init__

addJob(self, job, timeout=None)

source code 
Add a Job to the input queue.
Parameters:
  • timeout - If the input queue is full and timeout is None, block until a slot becomes available. If timeout > 0, block for up to timeout seconds and raise Queue.Full exception if the queue is still full. If timeout <= 0, do not block and raise Queue.Full immediately if the queue is full.

popProcessedJob(self, timeout=None)

source code 

Pop the next processed Job from the output queue.

If there are no pending jobs, it returns None. Otherwise:
  • If timeout is None, block until a job has finished and return it.
  • If timeout <= 0, return the first finished job that is immediately available without blocking, or None otherwise.
  • If timeout > 0, wait up to timeout seconds for a job to finish and return it; return None if no job has finished by the deadline.
Returns:
The next processed Job or None if there is no available for the given timeout.

processedJobs(self, timeout=None)

source code 
Return a list of processed jobs.
Parameters:
  • timeout - If timeout is None or timeout <= 0, it is equivalent to keep calling popProcessedJob until it returns None. If timeout > 0, this is the maximum overall time to spend on collecting processed jobs.

_assignJob(self, poll_time=10)

source code 

Pop the next unassigned non-cancelled job.

If there are no assigned jobs, keep polling every poll_time seconds until one comes in. If the job has been cancelled, it is silently discarded. This method should only be called by a Slave of this master.

_getProcessedJob(self, job)

source code 

Add a processed job in the output queue.

This method should only be called by a Slave of this master.