]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-99509: Add `__class_getitem__` to `multiprocessing.queues.Queue` (#99511)
authorNikita Sobolev <mail@sobolevn.me>
Tue, 27 Dec 2022 04:50:55 +0000 (07:50 +0300)
committerGitHub <noreply@github.com>
Tue, 27 Dec 2022 04:50:55 +0000 (20:50 -0800)
Lib/multiprocessing/queues.py
Lib/test/test_genericalias.py
Misc/NEWS.d/next/Library/2022-11-15-18-45-01.gh-issue-99509.FLK0xU.rst [new file with mode: 0644]

index f37f114a968871ba367ac33d5f0b109da8869834..daf9ee94a194318555e439aea1349e42b45f7cb2 100644 (file)
@@ -280,6 +280,8 @@ class Queue(object):
         import traceback
         traceback.print_exc()
 
+    __class_getitem__ = classmethod(types.GenericAlias)
+
 
 _sentinel = object()
 
index 6d0a556b1f7fe2f4701295eff7fb5978d7d09465..9b59d1e3e0aad2728239e93c45b71592f991610b 100644 (file)
@@ -31,11 +31,15 @@ try:
     from multiprocessing.managers import ValueProxy
     from multiprocessing.pool import ApplyResult
     from multiprocessing.queues import SimpleQueue as MPSimpleQueue
+    from multiprocessing.queues import Queue as MPQueue
+    from multiprocessing.queues import JoinableQueue as MPJoinableQueue
 except ImportError:
     # _multiprocessing module is optional
     ValueProxy = None
     ApplyResult = None
     MPSimpleQueue = None
+    MPQueue = None
+    MPJoinableQueue = None
 try:
     from multiprocessing.shared_memory import ShareableList
 except ImportError:
@@ -130,7 +134,8 @@ class BaseTest(unittest.TestCase):
     if ctypes is not None:
         generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
     if ValueProxy is not None:
-        generic_types.extend((ValueProxy, ApplyResult, MPSimpleQueue))
+        generic_types.extend((ValueProxy, ApplyResult,
+                              MPSimpleQueue, MPQueue, MPJoinableQueue))
 
     def test_subscriptable(self):
         for t in self.generic_types:
diff --git a/Misc/NEWS.d/next/Library/2022-11-15-18-45-01.gh-issue-99509.FLK0xU.rst b/Misc/NEWS.d/next/Library/2022-11-15-18-45-01.gh-issue-99509.FLK0xU.rst
new file mode 100644 (file)
index 0000000..6342810
--- /dev/null
@@ -0,0 +1 @@
+Add :pep:`585` support for :class:`multiprocessing.queues.Queue`.