summaryrefslogtreecommitdiffstats
path: root/Lib/queue.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2012-01-09 06:02:08 (GMT)
committerRaymond Hettinger <python@rcn.com>2012-01-09 06:02:08 (GMT)
commit61bd72924e805b0e563719863febb65ad96e91ae (patch)
tree39bd74dbd62b5b7d649d07d50169443c5b5d2104 /Lib/queue.py
parent143f51ade5a9769033c4826a2a20d540fa466714 (diff)
downloadcpython-61bd72924e805b0e563719863febb65ad96e91ae.zip
cpython-61bd72924e805b0e563719863febb65ad96e91ae.tar.gz
cpython-61bd72924e805b0e563719863febb65ad96e91ae.tar.bz2
Improve clarity with keyword argument for block. Move nowait methods together.
Diffstat (limited to 'Lib/queue.py')
-rw-r--r--Lib/queue.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/queue.py b/Lib/queue.py
index c65ba4b..c31310e 100644
--- a/Lib/queue.py
+++ b/Lib/queue.py
@@ -145,14 +145,6 @@ class Queue:
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 @@ class Queue:
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).