Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-99509: Add __class_getitem__ to multiprocessing.Queue #99511

Merged
merged 1 commit into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.