Package lib :: Module compat :: Class TaskQueue
[hide private]
[frames] | no frames]

Class TaskQueue

source code


Python 2.4 and earlier Queuing class replacement.

This code comes from http://code.activestate.com/recipes/475160/ and is part of the Python sources from 2.5 onwards.

Instance Methods [hide private]
 
__init__(self) source code
 
_put(self, item) source code
 
task_done(self)
Indicate that a formerly enqueued task is complete.
source code
 
join(self)
Blocks until all items in the Queue have been gotten and processed.
source code

Inherited from Queue.Queue: empty, full, get, get_nowait, put, put_nowait, qsize

Inherited from Queue.Queue (private): _get, _init, _qsize

Method Details [hide private]

__init__(self)
(Constructor)

source code 
Overrides: Queue.Queue.__init__

_put(self, item)

source code 
Overrides: Queue.Queue._put

task_done(self)

source code 

Indicate that a formerly enqueued task is complete.

Used by Queue consumer threads. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete.

If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue).

Raises a ValueError if called more times than there were items placed in the queue.

Overrides: Queue.Queue.task_done

join(self)

source code 

Blocks until all items in the Queue have been gotten and processed.

The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer thread calls task_done() to indicate the item was retrieved and all work on it is complete.

When the count of unfinished tasks drops to zero, join() unblocks.

Overrides: Queue.Queue.join