标签:
1 NAME 2 Queue - A multi-producer, multi-consumer queue. 3 4 CLASSES 5 Queue 6 LifoQueue 7 PriorityQueue 8 exceptions.Exception(exceptions.BaseException) 9 Empty 10 Full 11 12 class Empty(exceptions.Exception) 13 | Exception raised by Queue.get(block=0)/get_nowait(). 14 | 15 | Method resolution order: 16 | Empty 17 | exceptions.Exception 18 | exceptions.BaseException 19 | __builtin__.object 20 | 21 | Data descriptors defined here: 22 | 23 | __weakref__ 24 | list of weak references to the object (if defined) 25 | 26 | ---------------------------------------------------------------------- 27 | Methods inherited from exceptions.Exception: 28 | 29 | __init__(...) 30 | x.__init__(...) initializes x; see help(type(x)) for signature 31 | 32 | ---------------------------------------------------------------------- 33 | Data and other attributes inherited from exceptions.Exception: 34 | 35 | __new__ = <built-in method __new__ of type object> 36 | T.__new__(S, ...) -> a new object with type S, a subtype of T 37 | 38 | ---------------------------------------------------------------------- 39 | Methods inherited from exceptions.BaseException: 40 | 41 | __delattr__(...) 42 | x.__delattr__(‘name‘) <==> del x.name 43 | 44 | __getattribute__(...) 45 | x.__getattribute__(‘name‘) <==> x.name 46 | 47 | __getitem__(...) 48 | x.__getitem__(y) <==> x[y] 49 | 50 | __getslice__(...) 51 | x.__getslice__(i, j) <==> x[i:j] 52 | 53 | Use of negative indices is not supported. 54 | 55 | __reduce__(...) 56 | 57 | __repr__(...) 58 | x.__repr__() <==> repr(x) 59 | 60 | __setattr__(...) 61 | x.__setattr__(‘name‘, value) <==> x.name = value 62 | 63 | __setstate__(...) 64 | 65 | __str__(...) 66 | x.__str__() <==> str(x) 67 | 68 | __unicode__(...) 69 | 70 | ---------------------------------------------------------------------- 71 | Data descriptors inherited from exceptions.BaseException: 72 | 73 | __dict__ 74 | 75 | args 76 | 77 | message 78 79 class Full(exceptions.Exception) 80 | Exception raised by Queue.put(block=0)/put_nowait(). 81 | 82 | Method resolution order: 83 | Full 84 | exceptions.Exception 85 | exceptions.BaseException 86 | __builtin__.object 87 | 88 | Data descriptors defined here: 89 | 90 | __weakref__ 91 | list of weak references to the object (if defined) 92 | 93 | ---------------------------------------------------------------------- 94 | Methods inherited from exceptions.Exception: 95 | 96 | __init__(...) 97 | x.__init__(...) initializes x; see help(type(x)) for signature 98 | 99 | ---------------------------------------------------------------------- 100 | Data and other attributes inherited from exceptions.Exception: 101 | 102 | __new__ = <built-in method __new__ of type object> 103 | T.__new__(S, ...) -> a new object with type S, a subtype of T 104 | 105 | ---------------------------------------------------------------------- 106 | Methods inherited from exceptions.BaseException: 107 | 108 | __delattr__(...) 109 | x.__delattr__(‘name‘) <==> del x.name 110 | 111 | __getattribute__(...) 112 | x.__getattribute__(‘name‘) <==> x.name 113 | 114 | __getitem__(...) 115 | x.__getitem__(y) <==> x[y] 116 | 117 | __getslice__(...) 118 | x.__getslice__(i, j) <==> x[i:j] 119 | 120 | Use of negative indices is not supported. 121 | 122 | __reduce__(...) 123 | 124 | __repr__(...) 125 | x.__repr__() <==> repr(x) 126 | 127 | __setattr__(...) 128 | x.__setattr__(‘name‘, value) <==> x.name = value 129 | 130 | __setstate__(...) 131 | 132 | __str__(...) 133 | x.__str__() <==> str(x) 134 | 135 | __unicode__(...) 136 | 137 | ---------------------------------------------------------------------- 138 | Data descriptors inherited from exceptions.BaseException: 139 | 140 | __dict__ 141 | 142 | args 143 | 144 | message 145 146 class LifoQueue(Queue) 147 | Variant of Queue that retrieves most recently added entries first. 148 | 149 | Methods inherited from Queue: 150 | 151 | __init__(self, maxsize=0) 152 | 153 | empty(self) 154 | Return True if the queue is empty, False otherwise (not reliable!). 155 | 156 | full(self) 157 | Return True if the queue is full, False otherwise (not reliable!). 158 | 159 | get(self, block=True, timeout=None) 160 | Remove and return an item from the queue. 161 | 162 | If optional args ‘block‘ is true and ‘timeout‘ is None (the default), 163 | block if necessary until an item is available. If ‘timeout‘ is 164 | a non-negative number, it blocks at most ‘timeout‘ seconds and raises 165 | the Empty exception if no item was available within that time. 166 | Otherwise (‘block‘ is false), return an item if one is immediately 167 | available, else raise the Empty exception (‘timeout‘ is ignored 168 | in that case). 169 | 170 | get_nowait(self) 171 | Remove and return an item from the queue without blocking. 172 | 173 | Only get an item if one is immediately available. Otherwise 174 | raise the Empty exception. 175 | 176 | join(self) 177 | Blocks until all items in the Queue have been gotten and processed. 178 | 179 | The count of unfinished tasks goes up whenever an item is added to the 180 | queue. The count goes down whenever a consumer thread calls task_done() 181 | to indicate the item was retrieved and all work on it is complete. 182 | 183 | When the count of unfinished tasks drops to zero, join() unblocks. 184 | 185 | put(self, item, block=True, timeout=None) 186 | Put an item into the queue. 187 | 188 | If optional args ‘block‘ is true and ‘timeout‘ is None (the default), 189 | block if necessary until a free slot is available. If ‘timeout‘ is 190 | a non-negative number, it blocks at most ‘timeout‘ seconds and raises 191 | the Full exception if no free slot was available within that time. 192 | Otherwise (‘block‘ is false), put an item on the queue if a free slot 193 | is immediately available, else raise the Full exception (‘timeout‘ 194 | is ignored in that case). 195 | 196 | put_nowait(self, item) 197 | Put an item into the queue without blocking. 198 | 199 | Only enqueue the item if a free slot is immediately available. 200 | Otherwise raise the Full exception. 201 | 202 | qsize(self) 203 | Return the approximate size of the queue (not reliable!). 204 | 205 | task_done(self) 206 | Indicate that a formerly enqueued task is complete. 207 | 208 | Used by Queue consumer threads. For each get() used to fetch a task, 209 | a subsequent call to task_done() tells the queue that the processing 210 | on the task is complete. 211 | 212 | If a join() is currently blocking, it will resume when all items 213 | have been processed (meaning that a task_done() call was received 214 | for every item that had been put() into the queue). 215 | 216 | Raises a ValueError if called more times than there were items 217 | placed in the queue. 218 219 class PriorityQueue(Queue) 220 | Variant of Queue that retrieves open entries in priority order (lowest first). 221 | 222 | Entries are typically tuples of the form: (priority number, data). 223 | 224 | Methods inherited from Queue: 225 | 226 | __init__(self, maxsize=0) 227 | 228 | empty(self) 229 | Return True if the queue is empty, False otherwise (not reliable!). 230 | 231 | full(self) 232 | Return True if the queue is full, False otherwise (not reliable!). 233 | 234 | get(self, block=True, timeout=None) 235 | Remove and return an item from the queue. 236 | 237 | If optional args ‘block‘ is true and ‘timeout‘ is None (the default), 238 | block if necessary until an item is available. If ‘timeout‘ is 239 | a non-negative number, it blocks at most ‘timeout‘ seconds and raises 240 | the Empty exception if no item was available within that time. 241 | Otherwise (‘block‘ is false), return an item if one is immediately 242 | available, else raise the Empty exception (‘timeout‘ is ignored 243 | in that case). 244 | 245 | get_nowait(self) 246 | Remove and return an item from the queue without blocking. 247 | 248 | Only get an item if one is immediately available. Otherwise 249 | raise the Empty exception. 250 | 251 | join(self) 252 | Blocks until all items in the Queue have been gotten and processed. 253 | 254 | The count of unfinished tasks goes up whenever an item is added to the 255 | queue. The count goes down whenever a consumer thread calls task_done() 256 | to indicate the item was retrieved and all work on it is complete. 257 | 258 | When the count of unfinished tasks drops to zero, join() unblocks. 259 | 260 | put(self, item, block=True, timeout=None) 261 | Put an item into the queue. 262 | 263 | If optional args ‘block‘ is true and ‘timeout‘ is None (the default), 264 | block if necessary until a free slot is available. If ‘timeout‘ is 265 | a non-negative number, it blocks at most ‘timeout‘ seconds and raises 266 | the Full exception if no free slot was available within that time. 267 | Otherwise (‘block‘ is false), put an item on the queue if a free slot 268 | is immediately available, else raise the Full exception (‘timeout‘ 269 | is ignored in that case). 270 | 271 | put_nowait(self, item) 272 | Put an item into the queue without blocking. 273 | 274 | Only enqueue the item if a free slot is immediately available. 275 | Otherwise raise the Full exception. 276 | 277 | qsize(self) 278 | Return the approximate size of the queue (not reliable!). 279 | 280 | task_done(self) 281 | Indicate that a formerly enqueued task is complete. 282 | 283 | Used by Queue consumer threads. For each get() used to fetch a task, 284 | a subsequent call to task_done() tells the queue that the processing 285 | on the task is complete. 286 | 287 | If a join() is currently blocking, it will resume when all items 288 | have been processed (meaning that a task_done() call was received 289 | for every item that had been put() into the queue). 290 | 291 | Raises a ValueError if called more times than there were items 292 | placed in the queue. 293 294 class Queue 295 | Create a queue object with a given maximum size. 296 | 297 | If maxsize is <= 0, the queue size is infinite. 298 | 299 | Methods defined here: 300 | 301 | __init__(self, maxsize=0) 302 | 303 | empty(self) 304 | Return True if the queue is empty, False otherwise (not reliable!). 305 | 306 | full(self) 307 | Return True if the queue is full, False otherwise (not reliable!). 308 | 309 | get(self, block=True, timeout=None) 310 | Remove and return an item from the queue. 311 | 312 | If optional args ‘block‘ is true and ‘timeout‘ is None (the default), 313 | block if necessary until an item is available. If ‘timeout‘ is 314 | a non-negative number, it blocks at most ‘timeout‘ seconds and raises 315 | the Empty exception if no item was available within that time. 316 | Otherwise (‘block‘ is false), return an item if one is immediately 317 | available, else raise the Empty exception (‘timeout‘ is ignored 318 | in that case). 319 | 320 | get_nowait(self) 321 | Remove and return an item from the queue without blocking. 322 | 323 | Only get an item if one is immediately available. Otherwise 324 | raise the Empty exception. 325 | 326 | join(self) 327 | Blocks until all items in the Queue have been gotten and processed. 328 | 329 | The count of unfinished tasks goes up whenever an item is added to the 330 | queue. The count goes down whenever a consumer thread calls task_done() 331 | to indicate the item was retrieved and all work on it is complete. 332 | 333 | When the count of unfinished tasks drops to zero, join() unblocks. 334 | 335 | put(self, item, block=True, timeout=None) 336 | Put an item into the queue. 337 | 338 | If optional args ‘block‘ is true and ‘timeout‘ is None (the default), 339 | block if necessary until a free slot is available. If ‘timeout‘ is 340 | a non-negative number, it blocks at most ‘timeout‘ seconds and raises 341 | the Full exception if no free slot was available within that time. 342 | Otherwise (‘block‘ is false), put an item on the queue if a free slot 343 | is immediately available, else raise the Full exception (‘timeout‘ 344 | is ignored in that case). 345 | 346 | put_nowait(self, item) 347 | Put an item into the queue without blocking. 348 | 349 | Only enqueue the item if a free slot is immediately available. 350 | Otherwise raise the Full exception. 351 | 352 | qsize(self) 353 | Return the approximate size of the queue (not reliable!). 354 | 355 | task_done(self) 356 | Indicate that a formerly enqueued task is complete. 357 | 358 | Used by Queue consumer threads. For each get() used to fetch a task, 359 | a subsequent call to task_done() tells the queue that the processing 360 | on the task is complete. 361 | 362 | If a join() is currently blocking, it will resume when all items 363 | have been processed (meaning that a task_done() call was received 364 | for every item that had been put() into the queue). 365 | 366 | Raises a ValueError if called more times than there were items 367 | placed in the queue. 368 369 DATA 370 __all__ = [‘Empty‘, ‘Full‘, ‘Queue‘, ‘PriorityQueue‘, ‘LifoQueue‘]
标签:
原文地址:http://www.cnblogs.com/acode/p/4799920.html