2 # See https://docs.python.org/3/library/selectors.html
\r
4 from typing import Any, List, NamedTuple, Mapping, Tuple, Optional, Union
\r
5 from abc import ABCMeta, abstractmethod
\r
9 # Type aliases added mainly to preserve some context
\r
11 # See https://github.com/python/typeshed/issues/482
\r
12 # for details regarding how _FileObject is typed.
\r
13 _FileObject = Union[int, socket.socket]
\r
14 _FileDescriptor = int
\r
18 EVENT_READ = ... # type: _EventMask
\r
19 EVENT_WRITE = ... # type: _EventMask
\r
22 SelectorKey = NamedTuple('SelectorKey', [
\r
23 ('fileobj', _FileObject),
\r
24 ('fd', _FileDescriptor),
\r
25 ('events', _EventMask),
\r
30 class BaseSelector(metaclass=ABCMeta):
\r
32 def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
35 def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
\r
37 def modify(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
40 def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
\r
42 def close(self) -> None: ...
\r
44 def get_key(self, fileobj: _FileObject) -> SelectorKey: ...
\r
47 def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
\r
49 def __enter__(self) -> BaseSelector: ...
\r
51 def __exit__(self, *args: Any) -> None: ...
\r
53 class SelectSelector(BaseSelector):
\r
54 def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
55 def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
\r
56 def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
\r
57 def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
\r
59 class PollSelector(BaseSelector):
\r
60 def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
61 def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
\r
62 def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
\r
63 def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
\r
65 class EpollSelector(BaseSelector):
\r
66 def fileno(self) -> int: ...
\r
67 def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
68 def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
\r
69 def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
\r
70 def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
\r
72 class DevpollSelector(BaseSelector):
\r
73 def fileno(self) -> int: ...
\r
74 def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
75 def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
\r
76 def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
\r
77 def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
\r
79 class KqueueSelector(BaseSelector):
\r
80 def fileno(self) -> int: ...
\r
81 def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
82 def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
\r
83 def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
\r
84 def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
\r
86 class DefaultSelector(BaseSelector):
\r
87 def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
\r
88 def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
\r
89 def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
\r
90 def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
\r