Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit8bb6fae

Browse files
committed
Unblock getters after non-immediate queue shutdown
1 parentb4fe02f commit8bb6fae

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
ifself.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+
deftest_shutdown_get(self):
640+
defget():
641+
try:
642+
results.append(q.get())
643+
exceptExceptionase:
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
classQueueTest(BaseQueueTestMixin):
641658

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp