mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-08 21:25:32 +02:00
Use an iterator
This commit is contained in:
@@ -14,8 +14,8 @@ from dataclasses import dataclass
|
|||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from itertools import count
|
from itertools import count
|
||||||
from typing import (
|
from typing import (
|
||||||
IO, TYPE_CHECKING, Any, Dict, List, NoReturn, Optional, Sequence, Tuple,
|
IO, TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, NoReturn, Optional,
|
||||||
Union, cast
|
Tuple, Union, cast
|
||||||
)
|
)
|
||||||
|
|
||||||
from kitty.constants import kitty_exe, running_in_kitty
|
from kitty.constants import kitty_exe, running_in_kitty
|
||||||
@@ -281,14 +281,14 @@ def child_main(cmd: Dict[str, Any], ready_fd: int) -> NoReturn:
|
|||||||
if argv:
|
if argv:
|
||||||
sys.argv = list(argv)
|
sys.argv = list(argv)
|
||||||
poll = select.poll()
|
poll = select.poll()
|
||||||
poll.register(ready_fd, select.POLLIN | select.POLLERR | select.POLLHUP)
|
poll.register(ready_fd, select.POLLIN)
|
||||||
tuple(poll.poll())
|
tuple(poll.poll())
|
||||||
os.close(ready_fd)
|
os.close(ready_fd)
|
||||||
main_entry_point()
|
main_entry_point()
|
||||||
raise SystemExit(0)
|
raise SystemExit(0)
|
||||||
|
|
||||||
|
|
||||||
def fork(shm_address: str, all_non_child_fds: Sequence[int]) -> Tuple[int, int, int]:
|
def fork(shm_address: str, all_non_child_fds: Iterable[int]) -> Tuple[int, int, int]:
|
||||||
sz = pos = 0
|
sz = pos = 0
|
||||||
with SharedMemory(name=shm_address, unlink_on_exit=True) as shm:
|
with SharedMemory(name=shm_address, unlink_on_exit=True) as shm:
|
||||||
data = shm.read_data_with_size()
|
data = shm.read_data_with_size()
|
||||||
@@ -362,8 +362,12 @@ def main(stdin_fd: int, stdout_fd: int, notify_child_death_fd: int) -> None:
|
|||||||
warnings.filterwarnings('ignore', category=RuntimeWarning, module='runpy')
|
warnings.filterwarnings('ignore', category=RuntimeWarning, module='runpy')
|
||||||
prewarm()
|
prewarm()
|
||||||
|
|
||||||
def get_all_non_child_fds() -> Sequence[int]:
|
def get_all_non_child_fds() -> Iterator[int]:
|
||||||
return [notify_child_death_fd, stdin_fd, stdout_fd] + list(child_ready_fds.values()) + list(child_death_fds)
|
yield notify_child_death_fd
|
||||||
|
yield stdin_fd
|
||||||
|
yield stdout_fd
|
||||||
|
yield from child_ready_fds.values()
|
||||||
|
yield from child_death_fds.keys()
|
||||||
|
|
||||||
def check_event(event: int, err_msg: str) -> None:
|
def check_event(event: int, err_msg: str) -> None:
|
||||||
if event & select.POLLHUP:
|
if event & select.POLLHUP:
|
||||||
|
|||||||
Reference in New Issue
Block a user