Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8bb6fae

Browse filesBrowse files
committed
Unblock getters after non-immediate queue shutdown
1 parent b4fe02f commit 8bb6fae
Copy full SHA for 8bb6fae

File tree

Expand file treeCollapse file tree

2 files changed

+18
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-1
lines changed

‎Lib/queue.py

Copy file name to clipboardExpand all lines: Lib/queue.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ def shutdown(self, immediate=False):
249249
self._get()
250250
if self.unfinished_tasks > 0:
251251
self.unfinished_tasks -= 1
252-
self.not_empty.notify_all()
253252
# release all blocked threads in `join()`
254253
self.all_tasks_done.notify_all()
254+
self.not_empty.notify_all()
255255
self.not_full.notify_all()
256256

257257
# Override these methods to implement other queue organizations

‎Lib/test/test_queue.py

Copy file name to clipboardExpand all lines: Lib/test/test_queue.py
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,23 @@ def test_shutdown_get_task_done_join(self):
636636

637637
self.assertEqual(results, [True]*len(thrds))
638638

639+
def test_shutdown_get(self):
640+
def get():
641+
try:
642+
results.append(q.get())
643+
except Exception as e:
644+
results.append(e)
645+
646+
q = self.type2test()
647+
results = []
648+
get_thread = threading.Thread(target=get)
649+
get_thread.start()
650+
q.shutdown()
651+
get_thread.join(timeout=0.01)
652+
self.assertFalse(get_thread.is_alive())
653+
self.assertEqual(len(results), 1)
654+
self.assertIsInstance(results[0], self.queue.ShutDown)
655+
639656

640657
class QueueTest(BaseQueueTestMixin):
641658

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.