Changeset 10
- Timestamp:
- 05/25/07 03:07:53 (2 years ago)
- Files:
-
- 1 modified
-
trunk/turbomail/pool.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/turbomail/pool.py
r1 r10 60 60 log.debug("Thread pool created.") 61 61 62 def enqueue(self, work ):62 def enqueue(self, work, block=True, timeout=None): 63 63 """Enqueue a Message instance. 64 64 … … 69 69 instance of the Message class or subclass. 70 70 @type work: callable 71 72 @param block: Block code execution until there is a free slot in 73 the queue. If I{block} is True and I{timeout} is 74 None, block indefinately. 75 @type block: bool 76 77 @param timeout: How long to block execution (in seconds). If 78 the timeout expires (or block is false and the 79 queue is full) raise the Full exception. 80 @type timeout: int 71 81 """ 72 82 73 83 if callable(work): 74 self._queue.put(work() )84 self._queue.put(work(), block=block, timeout=timeout) 75 85 else: 76 self._queue.put(work )86 self._queue.put(work, block=block, timeout=timeout) 77 87 78 88 optimum_threads = min(self._threads, math.ceil(self._queue.qsize() / float(self._jobs)))
