2 from _typeshed import FileDescriptor, FileDescriptorLike, Self
3 from abc import ABCMeta, abstractmethod
4 from typing import Any, Mapping, NamedTuple
9 EVENT_WRITE: _EventMask
11 class SelectorKey(NamedTuple):
12 fileobj: FileDescriptorLike
17 class BaseSelector(metaclass=ABCMeta):
19 def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
21 def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
22 def modify(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
24 def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
25 def close(self) -> None: ...
26 def get_key(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
28 def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
29 def __enter__(self: Self) -> Self: ...
30 def __exit__(self, *args: Any) -> None: ...
32 class SelectSelector(BaseSelector):
33 def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
34 def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
35 def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
36 def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
38 if sys.platform != "win32":
39 class PollSelector(BaseSelector):
40 def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
41 def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
42 def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
43 def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
45 if sys.platform == "linux":
46 class EpollSelector(BaseSelector):
47 def fileno(self) -> int: ...
48 def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
49 def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
50 def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
51 def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
53 class DevpollSelector(BaseSelector):
54 def fileno(self) -> int: ...
55 def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
56 def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
57 def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
58 def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
60 class KqueueSelector(BaseSelector):
61 def fileno(self) -> int: ...
62 def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
63 def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
64 def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
65 def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
67 class DefaultSelector(BaseSelector):
68 def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = ...) -> SelectorKey: ...
69 def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
70 def select(self, timeout: float | None = ...) -> list[tuple[SelectorKey, _EventMask]]: ...
71 def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...