Skip to content

Commit 5d490b3

Browse files
committed
Unblock getters after non-immediate queue shutdown
1 parent b4fe02f commit 5d490b3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Lib/queue.py

Lines 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

Lines 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_simple(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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy