[Python-checkins] cpython: Improve clarity with keyword argument for block. Move nowait methods together.

raymond.hettinger python-checkins at python.org
Mon Jan 9 07:02:15 CET 2012


http://hg.python.org/cpython/rev/07608e67bc01
changeset:   74306:07608e67bc01
user:        Raymond Hettinger <python at rcn.com>
date:        Mon Jan 09 06:02:08 2012 +0000
summary:
  Improve clarity with keyword argument for block.  Move nowait methods together.

files:
  Lib/queue.py |  18 +++++++++---------
  1 files changed, 9 insertions(+), 9 deletions(-)


diff --git a/Lib/queue.py b/Lib/queue.py
--- a/Lib/queue.py
+++ b/Lib/queue.py
@@ -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).

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list