|
36 | 36 | import shlex |
37 | 37 | import subprocess |
38 | 38 | import typing as t |
| 39 | +from collections.abc import Sequence |
39 | 40 | from queue import Queue |
40 | 41 | from threading import Thread |
41 | | -from typing import Callable, List, Mapping, Optional, Sequence, Union |
| 42 | +from typing import Optional, Union |
42 | 43 |
|
43 | 44 | __all__ = 'Sub', 'call', 'call_in_thread', 'run', 'log' |
44 | 45 |
|
@@ -78,7 +79,7 @@ def __init__(self, cmd: Cmd, *, by_lines: bool = True, **kwargs: t.Any) -> None: |
78 | 79 | self.cmd = cmd |
79 | 80 | self.by_lines = by_lines |
80 | 81 | self.kwargs = dict(kwargs, **DEFAULTS) |
81 | | - self._threads: List[Thread] = [] |
| 82 | + self._threads: list[Thread] = [] |
82 | 83 |
|
83 | 84 | shell = kwargs.get('shell', False) |
84 | 85 | if isinstance(cmd, str): |
@@ -186,10 +187,10 @@ def log( |
186 | 187 | """ |
187 | 188 | return self.call(lambda x: print(out + x), lambda x: print(err + x)) |
188 | 189 |
|
189 | | - def join(self, timeout: Optional[int] = None) -> None: |
| 190 | + def join(self, timeout: int | None = None) -> None: |
190 | 191 | """Join the stream handling threads""" |
191 | | - for t in self._threads: |
192 | | - t.join(timeout) |
| 192 | + for th in self._threads: |
| 193 | + th.join(timeout) |
193 | 194 |
|
194 | 195 | def kill(self) -> None: |
195 | 196 | """Kill the running process, if any""" |
|
0 commit comments