Changeset 388 for python/vendor/current/Lib/Queue.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/Queue.py
r2 r388 2 2 3 3 from time import time as _time 4 try: 5 import threading as _threading 6 except ImportError: 7 import dummy_threading as _threading 4 8 from collections import deque 5 9 import heapq … … 21 25 """ 22 26 def __init__(self, maxsize=0): 23 try:24 import threading25 except ImportError:26 import dummy_threading as threading27 27 self.maxsize = maxsize 28 28 self._init(maxsize) … … 31 31 # is shared between the three conditions, so acquiring and 32 32 # releasing the conditions also acquires and releases mutex. 33 self.mutex = threading.Lock()33 self.mutex = _threading.Lock() 34 34 # Notify not_empty whenever an item is added to the queue; a 35 35 # thread waiting to get is notified then. 36 self.not_empty = threading.Condition(self.mutex)36 self.not_empty = _threading.Condition(self.mutex) 37 37 # Notify not_full whenever an item is removed from the queue; 38 38 # a thread waiting to put is notified then. 39 self.not_full = threading.Condition(self.mutex)39 self.not_full = _threading.Condition(self.mutex) 40 40 # Notify all_tasks_done whenever the number of unfinished tasks 41 41 # drops to zero; thread waiting to join() is notified to resume 42 self.all_tasks_done = threading.Condition(self.mutex)42 self.all_tasks_done = _threading.Condition(self.mutex) 43 43 self.unfinished_tasks = 0 44 44 … … 110 110 If optional args 'block' is true and 'timeout' is None (the default), 111 111 block if necessary until a free slot is available. If 'timeout' is 112 a positive number, it blocks at most 'timeout' seconds and raises112 a non-negative number, it blocks at most 'timeout' seconds and raises 113 113 the Full exception if no free slot was available within that time. 114 114 Otherwise ('block' is false), put an item on the queue if a free slot … … 126 126 self.not_full.wait() 127 127 elif timeout < 0: 128 raise ValueError("'timeout' must be a positive number")128 raise ValueError("'timeout' must be a non-negative number") 129 129 else: 130 130 endtime = _time() + timeout … … 153 153 If optional args 'block' is true and 'timeout' is None (the default), 154 154 block if necessary until an item is available. If 'timeout' is 155 a positive number, it blocks at most 'timeout' seconds and raises155 a non-negative number, it blocks at most 'timeout' seconds and raises 156 156 the Empty exception if no item was available within that time. 157 157 Otherwise ('block' is false), return an item if one is immediately … … 168 168 self.not_empty.wait() 169 169 elif timeout < 0: 170 raise ValueError("'timeout' must be a positive number")170 raise ValueError("'timeout' must be a non-negative number") 171 171 else: 172 172 endtime = _time() + timeout
Note:
See TracChangeset
for help on using the changeset viewer.