summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-27 16:11:10 (GMT)
committerGitHub <noreply@github.com>2020-04-27 16:11:10 (GMT)
commit9adccc1384568f4d46e37f698cb3e3a4f6ca0252 (patch)
treef12424600659c0171b2f70f6ab97060c9a31b977 /Lib/test/_test_multiprocessing.py
parentc5c42815ecb560bbf34db99b0e15fe9b604be889 (diff)
downloadcpython-9adccc1384568f4d46e37f698cb3e3a4f6ca0252.zip
cpython-9adccc1384568f4d46e37f698cb3e3a4f6ca0252.tar.gz
cpython-9adccc1384568f4d46e37f698cb3e3a4f6ca0252.tar.bz2
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
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 083ad53..dd894f2 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -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):