Skip to content

Commit 74dd0c8

Browse files
committed
pythongh-99509: Add __class_getitem__ to multiprocessing.Qeueu
1 parent 73943cb commit 74dd0c8

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Lib/multiprocessing/queues.py

+2
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ def _on_queue_feeder_error(e, obj):
280280
import traceback
281281
traceback.print_exc()
282282

283+
__class_getitem__ = classmethod(types.GenericAlias)
284+
283285

284286
_sentinel = object()
285287

Lib/test/test_genericalias.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@
3131
from multiprocessing.managers import ValueProxy
3232
from multiprocessing.pool import ApplyResult
3333
from multiprocessing.queues import SimpleQueue as MPSimpleQueue
34+
from multiprocessing.queues import Queue as MPQueue
35+
from multiprocessing.queues import JoinableQueue as MPJoinableQueue
3436
except ImportError:
3537
# _multiprocessing module is optional
3638
ValueProxy = None
3739
ApplyResult = None
3840
MPSimpleQueue = None
41+
MPQueue = None
42+
MPJoinableQueue = None
3943
try:
4044
from multiprocessing.shared_memory import ShareableList
4145
except ImportError:
@@ -130,7 +134,8 @@ class BaseTest(unittest.TestCase):
130134
if ctypes is not None:
131135
generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
132136
if ValueProxy is not None:
133-
generic_types.extend((ValueProxy, ApplyResult, MPSimpleQueue))
137+
generic_types.extend((ValueProxy, ApplyResult,
138+
MPSimpleQueue, MPQueue, MPJoinableQueue))
134139

135140
def test_subscriptable(self):
136141
for t in self.generic_types:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add :pep:`585` support for :class:`multiprocessing.queues.Queue`.

0 commit comments

Comments
 (0)