mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-99509: Add __class_getitem__
to multiprocessing.queues.Queue
(#99511)
This commit is contained in:
parent
199507b81a
commit
ce39aaffee
3 changed files with 9 additions and 1 deletions
|
@ -280,6 +280,8 @@ class Queue(object):
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
__class_getitem__ = classmethod(types.GenericAlias)
|
||||||
|
|
||||||
|
|
||||||
_sentinel = object()
|
_sentinel = object()
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,15 @@ try:
|
||||||
from multiprocessing.managers import ValueProxy
|
from multiprocessing.managers import ValueProxy
|
||||||
from multiprocessing.pool import ApplyResult
|
from multiprocessing.pool import ApplyResult
|
||||||
from multiprocessing.queues import SimpleQueue as MPSimpleQueue
|
from multiprocessing.queues import SimpleQueue as MPSimpleQueue
|
||||||
|
from multiprocessing.queues import Queue as MPQueue
|
||||||
|
from multiprocessing.queues import JoinableQueue as MPJoinableQueue
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# _multiprocessing module is optional
|
# _multiprocessing module is optional
|
||||||
ValueProxy = None
|
ValueProxy = None
|
||||||
ApplyResult = None
|
ApplyResult = None
|
||||||
MPSimpleQueue = None
|
MPSimpleQueue = None
|
||||||
|
MPQueue = None
|
||||||
|
MPJoinableQueue = None
|
||||||
try:
|
try:
|
||||||
from multiprocessing.shared_memory import ShareableList
|
from multiprocessing.shared_memory import ShareableList
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -130,7 +134,8 @@ class BaseTest(unittest.TestCase):
|
||||||
if ctypes is not None:
|
if ctypes is not None:
|
||||||
generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
|
generic_types.extend((ctypes.Array, ctypes.LibraryLoader))
|
||||||
if ValueProxy is not None:
|
if ValueProxy is not None:
|
||||||
generic_types.extend((ValueProxy, ApplyResult, MPSimpleQueue))
|
generic_types.extend((ValueProxy, ApplyResult,
|
||||||
|
MPSimpleQueue, MPQueue, MPJoinableQueue))
|
||||||
|
|
||||||
def test_subscriptable(self):
|
def test_subscriptable(self):
|
||||||
for t in self.generic_types:
|
for t in self.generic_types:
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add :pep:`585` support for :class:`multiprocessing.queues.Queue`.
|
Loading…
Add table
Add a link
Reference in a new issue