bpo-30966: Add multiprocessing.SimpleQueue.close() (GH-19735)

Add a new close() method to multiprocessing.SimpleQueue to explicitly
close the queue.

Automerge-Triggered-By: @pitrou
This commit is contained in:
Victor Stinner 2020-04-27 18:11:10 +02:00 committed by GitHub
parent c5c42815ec
commit 9adccc1384
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 0 deletions

View file

@ -5244,6 +5244,20 @@ class TestSimpleQueue(unittest.TestCase):
proc.join()
def test_close(self):
queue = multiprocessing.SimpleQueue()
queue.close()
# closing a queue twice should not fail
queue.close()
# Test specific to CPython since it tests private attributes
@test.support.cpython_only
def test_closed(self):
queue = multiprocessing.SimpleQueue()
queue.close()
self.assertTrue(queue._reader.closed)
self.assertTrue(queue._writer.closed)
class TestPoolNotLeakOnFailure(unittest.TestCase):