gh-117531: Unblock getters after non-immediate queue shutdown (#117532)

(This is a small tweak of the original gh-104750 which added shutdown.)
This commit is contained in:
Laurie O 2024-04-11 01:01:42 +10:00 committed by GitHub
parent dfcae4379f
commit 6bc0b33a91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 5 deletions

View file

@ -636,6 +636,23 @@ class BaseQueueTestMixin(BlockingTestMixin):
self.assertEqual(results, [True]*len(thrds))
def test_shutdown_pending_get(self):
def get():
try:
results.append(q.get())
except Exception as e:
results.append(e)
q = self.type2test()
results = []
get_thread = threading.Thread(target=get)
get_thread.start()
q.shutdown(immediate=False)
get_thread.join(timeout=10.0)
self.assertFalse(get_thread.is_alive())
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0], self.queue.ShutDown)
class QueueTest(BaseQueueTestMixin):