bpo-22872: multiprocessing.Queue's put() and get() now raise ValueError if the queue is closed. (GH-9010)

Previously, put() and get() would raise AssertionError and OSError,
respectively.
This commit is contained in:
Zackery Spytz 2018-10-13 03:26:09 -06:00 committed by Serhiy Storchaka
parent e385d0661e
commit 0461704060
4 changed files with 26 additions and 2 deletions

View file

@ -1114,6 +1114,14 @@ class _TestQueue(BaseTestCase):
# Assert that the serialization and the hook have been called correctly
self.assertTrue(not_serializable_obj.reduce_was_called)
self.assertTrue(not_serializable_obj.on_queue_feeder_error_was_called)
def test_closed_queue_put_get_exceptions(self):
for q in multiprocessing.Queue(), multiprocessing.JoinableQueue():
q.close()
with self.assertRaisesRegex(ValueError, 'is closed'):
q.put('foo')
with self.assertRaisesRegex(ValueError, 'is closed'):
q.get()
#
#
#