Scientific.DistributedComputing.TaskManager.TaskQueue

Package Scientific :: Package DistributedComputing :: Module TaskManager :: Class TaskQueue |
[frames] | no frames]

# Class TaskQueue

    object --+
             |
            TaskQueue

A FIFO queue for tasks. This class is thread-safe.

Instance Methods
__init__(self) x.__init__(...) initializes x; see x.__class__.__doc__ for signature |
`int` |
__len__(self) Returns: the number of tasks in the queue |
addTask(self, task, in_front=False) |
Task Removes the first task from the queue and returns it. If the task queue is empty, the method blocks until a task becomes available. |
firstTask(self) Returns: the first task in the queue |
Task Removes the first task with the given tag from the queue and returns it. If no task with the requested tag is available, the method blocks until a matching task becomes available. |
firstTaskWithTag(self, tag) Returns: the first task in the queue |
`dict` |
taskCount(self) Returns: a dictionary listing the number of tasks for each tag |
Task Removes the task with the given task_id from the queue and returns it. If the task is not in the queue, the method blocks until it becomes available. |
taskWithId(self, task_id) Returns: the task with the given task_id |
terminateWaitingThreads(self) Makes all threads waiting for a task raise TaskManagerTermination. |
Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self) (Constructor) |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Overrides: object.__init__ (inherited documentation)

### __len__(self) (Length operator) |
Returns: `int` the number of tasks in the queue

### addTask(self, task, in_front=False) |
Parameters: `task` (Task) - the task to be added `in_front` (`bool`) - if `True`, add the task at the beginning of the queue (this is for re-scheduling tasks that were rejected or not properly handled). Otherwise, add the task at the end of the queue.

### firstTask(self) |
Returns: Task Removes the first task from the queue and returns it. If the task queue is empty, the method blocks until a task becomes available. the first task in the queue

### firstTaskWithTag(self, tag) |
Parameters: `tag` (`str`) - a task tag Returns: Task Removes the first task with the given tag from the queue and returns it. If no task with the requested tag is available, the method blocks until a matching task becomes available. the first task in the queue

### taskCount(self) |
Returns: `dict` a dictionary listing the number of tasks for each tag

### taskWithId(self, task_id) |
Parameters: `task_id` (`str`) - a task id Returns: Task Removes the task with the given task_id from the queue and returns it. If the task is not in the queue, the method blocks until it becomes available. the task with the given task_id