mypy: Improve type annotation of run_parallel in zerver/lib/parallel.py.

This commit is contained in:
neiljp (Neil Pilgrim)
2017-08-07 20:27:06 -07:00
parent 05ef052ef5
commit 7d6d8fc848

View File

@@ -1,16 +1,18 @@
from typing import Any, Dict, Generator, Iterable, Tuple
from typing import Dict, Iterable, Tuple, Callable, TypeVar, Iterator
import os
import pty
import sys
import errno
JobData = TypeVar('JobData')
def run_parallel(job, data, threads=6):
# type: (Any, Iterable[Any], int) -> Generator[Tuple[int, Any], None, None]
pids = {} # type: Dict[int, Any]
# type: (Callable[[JobData], int], Iterable[JobData], int) -> Iterator[Tuple[int, JobData]]
pids = {} # type: Dict[int, JobData]
def wait_for_one():
# type: () -> Tuple[int, Any]
# type: () -> Tuple[int, JobData]
while True:
try:
(pid, status) = os.wait()