summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2022-12-27 04:50:55 (GMT)
committerGitHub <noreply@github.com>2022-12-27 04:50:55 (GMT)
commitce39aaffeef9aa8af54a8554fe7a5609a6bba471 (patch)
tree53c1d93a4eccf9536a3b2c38d53923cbca5cf517 /Lib
parent199507b81a302ea19f93593965b1e5088195a6c5 (diff)
downloadcpython-ce39aaffeef9aa8af54a8554fe7a5609a6bba471.zip
cpython-ce39aaffeef9aa8af54a8554fe7a5609a6bba471.tar.gz
cpython-ce39aaffeef9aa8af54a8554fe7a5609a6bba471.tar.bz2
gh-99509: Add `__class_getitem__` to `multiprocessing.queues.Queue` (#99511)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/queues.py2
-rw-r--r--Lib/test/test_genericalias.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index f37f114..daf9ee9 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -280,6 +280,8 @@ class Queue(object):
import traceback
traceback.print_exc()
+ __class_getitem__ = classmethod(types.GenericAlias)
+
_sentinel = object()
diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py
index 6d0a556..9b59d1e 100644
--- a/Lib/test/test_genericalias.py
+++ b/Lib/test/test_genericalias.py
@@ -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: