mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 10:57:58 +00:00
mypy: Improve type annotation of run_parallel in zerver/lib/parallel.py.
This commit is contained in:
@@ -1,16 +1,18 @@
|
|||||||
from typing import Any, Dict, Generator, Iterable, Tuple
|
from typing import Dict, Iterable, Tuple, Callable, TypeVar, Iterator
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pty
|
import pty
|
||||||
import sys
|
import sys
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
|
JobData = TypeVar('JobData')
|
||||||
|
|
||||||
def run_parallel(job, data, threads=6):
|
def run_parallel(job, data, threads=6):
|
||||||
# type: (Any, Iterable[Any], int) -> Generator[Tuple[int, Any], None, None]
|
# type: (Callable[[JobData], int], Iterable[JobData], int) -> Iterator[Tuple[int, JobData]]
|
||||||
pids = {} # type: Dict[int, Any]
|
pids = {} # type: Dict[int, JobData]
|
||||||
|
|
||||||
def wait_for_one():
|
def wait_for_one():
|
||||||
# type: () -> Tuple[int, Any]
|
# type: () -> Tuple[int, JobData]
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
(pid, status) = os.wait()
|
(pid, status) = os.wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user