mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Make multiprocessing.Queue a subclass of queue.Queue (#1525)
Also change multiprocessing.Queue's put and get timeout arguments to allow None. This fixes a problem with logging.handlers.QueueHandler and QueueListener not accepting a multiprocessing.Queue as the queue argument. Declaring the Queue now needs to note what it will be used for. eg. q = multiprocessing.Queue() # type: multiprocessing.Queue[List[Any]]
This commit is contained in:
committed by
Guido van Rossum
parent
228615b307
commit
19275ea38a
@@ -1,6 +1,6 @@
|
||||
# Stubs for multiprocessing
|
||||
|
||||
from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List, Union
|
||||
from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List, Union, TypeVar
|
||||
|
||||
from logging import Logger
|
||||
from multiprocessing.context import BaseContext
|
||||
@@ -8,6 +8,9 @@ from multiprocessing.managers import SyncManager
|
||||
from multiprocessing.pool import AsyncResult
|
||||
from multiprocessing.process import current_process as current_process
|
||||
import sys
|
||||
import queue
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
class Lock():
|
||||
def acquire(self, block: bool = ..., timeout: int = ...) -> None: ...
|
||||
@@ -93,15 +96,15 @@ class Process():
|
||||
def is_alive(self) -> bool: ...
|
||||
def join(self, timeout: Optional[float] = ...) -> None: ...
|
||||
|
||||
class Queue():
|
||||
class Queue(queue.Queue[_T]):
|
||||
def __init__(self, maxsize: int = ...) -> None: ...
|
||||
def get(self, block: bool = ..., timeout: float = ...) -> Any: ...
|
||||
def put(self, item: Any, block: bool = ..., timeout: float = ...) -> None: ...
|
||||
def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ...
|
||||
def put(self, item: _T, block: bool = ..., timeout: Optional[float] = ...) -> None: ...
|
||||
def qsize(self) -> int: ...
|
||||
def empty(self) -> bool: ...
|
||||
def full(self) -> bool: ...
|
||||
def put_nowait(self, item: Any) -> None: ...
|
||||
def get_nowait(self) -> Any: ...
|
||||
def put_nowait(self, item: _T) -> None: ...
|
||||
def get_nowait(self) -> _T: ...
|
||||
def close(self) -> None: ...
|
||||
def join_thread(self) -> None: ...
|
||||
def cancel_join_thread(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user