Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 61bd729

Browse files
committed
Improve clarity with keyword argument for block. Move nowait methods together.
1 parent 143f51a commit 61bd729

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Lib/queue.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ def put(self, item, block=True, timeout=None):
145145
self.unfinished_tasks += 1
146146
self.not_empty.notify()
147147

148-
def put_nowait(self, item):
149-
"""Put an item into the queue without blocking.
150-
151-
Only enqueue the item if a free slot is immediately available.
152-
Otherwise raise the Full exception.
153-
"""
154-
return self.put(item, False)
155-
156148
def get(self, block=True, timeout=None):
157149
"""Remove and return an item from the queue.
158150
@@ -184,13 +176,21 @@ def get(self, block=True, timeout=None):
184176
self.not_full.notify()
185177
return item
186178

179+
def put_nowait(self, item):
180+
"""Put an item into the queue without blocking.
181+
182+
Only enqueue the item if a free slot is immediately available.
183+
Otherwise raise the Full exception.
184+
"""
185+
return self.put(item, block=False)
186+
187187
def get_nowait(self):
188188
"""Remove and return an item from the queue without blocking.
189189
190190
Only get an item if one is immediately available. Otherwise
191191
raise the Empty exception.
192192
"""
193-
return self.get(False)
193+
return self.get(block=False)
194194

195195
# Override these methods to implement other queue organizations
196196
# (e.g. stack or priority queue).

0 commit comments

Comments
 (0)