Package pulp :: Package server :: Package tasking :: Package queue :: Module fifo :: Class FIFOTaskQueue
[hide private]
[frames] | no frames]

Class FIFOTaskQueue

source code

    object --+    
             |    
base.TaskQueue --+
                 |
                FIFOTaskQueue

Task queue with threaded dispatcher that fires off tasks in the order in which they were enqueued and stores the finished tasks for a specified amount of time.

Instance Methods [hide private]
 
__init__(self, max_running=4, finished_lifetime=timedelta(seconds=3600))
Returns: FIFOTaskQueue instance
source code
 
_dispatch(self)
Scheduling method that that executes the scheduling hooks.
source code
 
_get_tasks(self)
Get the next 'n' tasks to run, where is max - currently running tasks
source code
 
_cancel_tasks(self)
Stop any tasks that have been flagged as canceled.
source code
 
_timeout_tasks(self)
Stop tasks that have met or exceeded their timeout length.
source code
 
_cull_tasks(self)
Clean up finished task data
source code
 
enqueue(self, task, unique=False)
Add a task to the task queue
source code
 
run(self, task)
Run a task from this task queue
source code
 
complete(self, task)
Mark a task run as completed
source code
 
cancel(self, task)
Cancel a running task.
source code
 
find(self, **kwargs)
Find a task in this task queue.
source code

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

    Inherited from base.TaskQueue
 
exists(self, task, criteria, include_finished=True)
Returns whether or not the given task exists in this queue.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, max_running=4, finished_lifetime=timedelta(seconds=3600))
(Constructor)

source code 

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

Parameters:
  • max_running (int) - maximum number of tasks to run simultaneously None means indefinitely
  • finished_lifetime (datetime.timedelta instance) - length of time to keep finished tasks
Returns:
FIFOTaskQueue instance
Overrides: object.__init__

enqueue(self, task, unique=False)

source code 

Add a task to the task queue

Parameters:
  • task - Task instance
  • unique - If True, the task will only be added if there are no non-finished tasks with the same method_name, args, and kwargs; otherwise the task will always be added
Returns:
True if a new task was created; False if it was rejected (due to the unique flag
Overrides: base.TaskQueue.enqueue
(inherited documentation)

run(self, task)

source code 

Run a task from this task queue

Parameters:
  • task - Task instance
Overrides: base.TaskQueue.run
(inherited documentation)

complete(self, task)

source code 

Mark a task run as completed

Parameters:
  • task - Task instance
Overrides: base.TaskQueue.complete
(inherited documentation)

cancel(self, task)

source code 

Cancel a running task.

Parameters:
  • task - Task instance
Overrides: base.TaskQueue.cancel
(inherited documentation)

find(self, **kwargs)

source code 

Find a task in this task queue. Only the oldest task in the queue will be returned.

Parameters:
  • kwargs - task attributes and values as search criteria
Returns:
Task instance on success, None otherwise
Overrides: base.TaskQueue.find
(inherited documentation)