Mercurial > cpython-lru_cache-weakref
diff Lib/queue.py @ 74306:07608e67bc01
Improve clarity with keyword argument for block. Move nowait methods together.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Mon, 09 Jan 2012 06:02:08 +0000 |
| parents | 190ad17f5a87 |
| children | ca2a35140e6a |
line wrap: on
line diff
--- a/Lib/queue.py Mon Jan 09 05:32:01 2012 +0000 +++ b/Lib/queue.py Mon Jan 09 06:02:08 2012 +0000 @@ -145,14 +145,6 @@ self.unfinished_tasks += 1 self.not_empty.notify() - def put_nowait(self, item): - """Put an item into the queue without blocking. - - Only enqueue the item if a free slot is immediately available. - Otherwise raise the Full exception. - """ - return self.put(item, False) - def get(self, block=True, timeout=None): """Remove and return an item from the queue. @@ -184,13 +176,21 @@ self.not_full.notify() return item + def put_nowait(self, item): + """Put an item into the queue without blocking. + + Only enqueue the item if a free slot is immediately available. + Otherwise raise the Full exception. + """ + return self.put(item, block=False) + def get_nowait(self): """Remove and return an item from the queue without blocking. Only get an item if one is immediately available. Otherwise raise the Empty exception. """ - return self.get(False) + return self.get(block=False) # Override these methods to implement other queue organizations # (e.g. stack or priority queue).
