1
1
import sys
2
2
import types
3
3
from _typeshed import Self
4
+ from abc import ABCMeta , abstractmethod
4
5
from socket import socket
5
6
from typing import Any , Callable
7
+ from typing_extensions import Literal
6
8
7
9
from .base_events import Server
8
10
from .events import AbstractEventLoop , BaseDefaultEventLoopPolicy , _ProtocolFactory , _SSLContext
@@ -12,13 +14,20 @@ from .selector_events import BaseSelectorEventLoop
12
14
# but other parts of typeshed need this defintion.
13
15
# So, it is special cased.
14
16
class AbstractChildWatcher :
17
+ @abstractmethod
15
18
def add_child_handler (self , pid : int , callback : Callable [..., Any ], * args : Any ) -> None : ...
19
+ @abstractmethod
16
20
def remove_child_handler (self , pid : int ) -> bool : ...
21
+ @abstractmethod
17
22
def attach_loop (self , loop : AbstractEventLoop | None ) -> None : ...
23
+ @abstractmethod
18
24
def close (self ) -> None : ...
25
+ @abstractmethod
19
26
def __enter__ (self : Self ) -> Self : ...
27
+ @abstractmethod
20
28
def __exit__ (self , typ : type [BaseException ] | None , exc : BaseException | None , tb : types .TracebackType | None ) -> None : ...
21
29
if sys .version_info >= (3 , 8 ):
30
+ @abstractmethod
22
31
def is_active (self ) -> bool : ...
23
32
24
33
if sys .platform != "win32" :
@@ -48,14 +57,23 @@ if sys.platform != "win32":
48
57
else :
49
58
__all__ = ["SelectorEventLoop" , "AbstractChildWatcher" , "SafeChildWatcher" , "FastChildWatcher" , "DefaultEventLoopPolicy" ]
50
59
51
- class BaseChildWatcher (AbstractChildWatcher ):
60
+ class BaseChildWatcher (AbstractChildWatcher , metaclass = ABCMeta ):
52
61
def __init__ (self ) -> None : ...
62
+ def close (self ) -> None : ...
63
+ def is_active (self ) -> bool : ...
64
+ def attach_loop (self , loop : AbstractEventLoop | None ) -> None : ...
53
65
54
66
class SafeChildWatcher (BaseChildWatcher ):
55
67
def __enter__ (self : Self ) -> Self : ...
68
+ def __exit__ (self , a : type [BaseException ] | None , b : BaseException | None , c : types .TracebackType | None ) -> None : ...
69
+ def add_child_handler (self , pid : int , callback : Callable [..., Any ], * args : Any ) -> None : ...
70
+ def remove_child_handler (self , pid : int ) -> bool : ...
56
71
57
72
class FastChildWatcher (BaseChildWatcher ):
58
73
def __enter__ (self : Self ) -> Self : ...
74
+ def __exit__ (self , a : type [BaseException ] | None , b : BaseException | None , c : types .TracebackType | None ) -> None : ...
75
+ def add_child_handler (self , pid : int , callback : Callable [..., Any ], * args : Any ) -> None : ...
76
+ def remove_child_handler (self , pid : int ) -> bool : ...
59
77
60
78
class _UnixSelectorEventLoop (BaseSelectorEventLoop ):
61
79
if sys .version_info < (3 , 7 ):
@@ -86,8 +104,39 @@ if sys.platform != "win32":
86
104
) -> None : ...
87
105
88
106
class MultiLoopChildWatcher (AbstractChildWatcher ):
107
+ def __init__ (self ) -> None : ...
108
+ def is_active (self ) -> bool : ...
109
+ def close (self ) -> None : ...
89
110
def __enter__ (self : Self ) -> Self : ...
111
+ def __exit__ (
112
+ self , exc_type : type [BaseException ] | None , exc_val : BaseException | None , exc_tb : types .TracebackType | None
113
+ ) -> None : ...
114
+ def add_child_handler (self , pid : int , callback : Callable [..., Any ], * args : Any ) -> None : ...
115
+ def remove_child_handler (self , pid : int ) -> bool : ...
116
+ def attach_loop (self , loop : AbstractEventLoop | None ) -> None : ...
90
117
91
118
class ThreadedChildWatcher (AbstractChildWatcher ):
119
+ def __init__ (self ) -> None : ...
120
+ def is_active (self ) -> Literal [True ]: ...
121
+ def close (self ) -> None : ...
92
122
def __enter__ (self : Self ) -> Self : ...
123
+ def __exit__ (
124
+ self , exc_type : type [BaseException ] | None , exc_val : BaseException | None , exc_tb : types .TracebackType | None
125
+ ) -> None : ...
93
126
def __del__ (self , _warn : _Warn = ...) -> None : ...
127
+ def add_child_handler (self , pid : int , callback : Callable [..., Any ], * args : Any ) -> None : ...
128
+ def remove_child_handler (self , pid : int ) -> bool : ...
129
+ def attach_loop (self , loop : AbstractEventLoop | None ) -> None : ...
130
+
131
+ if sys .version_info >= (3 , 9 ):
132
+ class PidfdChildWatcher (AbstractChildWatcher ):
133
+ def __init__ (self ) -> None : ...
134
+ def __enter__ (self : Self ) -> Self : ...
135
+ def __exit__ (
136
+ self , exc_type : type [BaseException ] | None , exc_val : BaseException | None , exc_tb : types .TracebackType | None
137
+ ) -> None : ...
138
+ def is_active (self ) -> bool : ...
139
+ def close (self ) -> None : ...
140
+ def attach_loop (self , loop : AbstractEventLoop | None ) -> None : ...
141
+ def add_child_handler (self , pid : int , callback : Callable [..., Any ], * args : Any ) -> None : ...
142
+ def remove_child_handler (self , pid : int ) -> bool : ...
0 commit comments