Skip to content

Commit

Permalink
gh-99509: Add __class_getitem__ to multiprocessing.queues.Queue (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Dec 27, 2022
1 parent 199507b commit ce39aaf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Lib/multiprocessing/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def _on_queue_feeder_error(e, obj):
import traceback
traceback.print_exc()

__class_getitem__ = classmethod(types.GenericAlias)


_sentinel = object()

Expand Down
7 changes: 6 additions & 1 deletion Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
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:
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :pep:`585` support for :class:`multiprocessing.queues.Queue`.

0 comments on commit ce39aaf

Please sign in to comment.