Debian Codegraph @

jedi/third_party/typeshed/stdlib/threading.pyi

raw symbols SCIP
1 import _thread
2 import sys
3 from _thread import _ExceptHookArgs, get_native_id as get_native_id
4 from _typeshed import ProfileFunction, TraceFunction
5 from collections.abc import Callable, Iterable, Mapping
6 from contextvars import Context
7 from types import TracebackType
8 from typing import Any, Final, TypeVar, final
9 from typing_extensions import deprecated
10
11 _T = TypeVar("_T")
12
13 __all__ = [
14 "get_ident",
15 "active_count",
16 "Condition",
17 "current_thread",
18 "enumerate",
19 "main_thread",
20 "TIMEOUT_MAX",
21 "Event",
22 "Lock",
23 "RLock",
24 "Semaphore",
25 "BoundedSemaphore",
26 "Thread",
27 "Barrier",
28 "BrokenBarrierError",
29 "Timer",
30 "ThreadError",
31 "ExceptHookArgs",
32 "setprofile",
33 "settrace",
34 "local",
35 "stack_size",
36 "excepthook",
37 "get_native_id",
38 ]
39
40 if sys.version_info >= (3, 10):
41 __all__ += ["getprofile", "gettrace"]
42
43 if sys.version_info >= (3, 12):
44 __all__ += ["setprofile_all_threads", "settrace_all_threads"]
45
46 _profile_hook: ProfileFunction | None
47
48 def active_count() -> int: ...
49 @deprecated("Deprecated since Python 3.10. Use `active_count()` instead.")
50 def activeCount() -> int: ...
51 def current_thread() -> Thread: ...
52 @deprecated("Deprecated since Python 3.10. Use `current_thread()` instead.")
53 def currentThread() -> Thread: ...
54 def get_ident() -> int: ...
55 def enumerate() -> list[Thread]: ...
56 def main_thread() -> Thread: ...
57 def settrace(func: TraceFunction | None) -> None: ...
58 def setprofile(func: ProfileFunction | None) -> None: ...
59
60 if sys.version_info >= (3, 12):
61 def setprofile_all_threads(func: ProfileFunction | None) -> None: ...
62 def settrace_all_threads(func: TraceFunction | None) -> None: ...
63
64 if sys.version_info >= (3, 10):
65 def gettrace() -> TraceFunction | None: ...
66 def getprofile() -> ProfileFunction | None: ...
67
68 def stack_size(size: int = 0, /) -> int: ...
69
70 TIMEOUT_MAX: Final[float]
71
72 ThreadError = _thread.error
73 local = _thread._local
74
75 class Thread:
76 name: str
77 @property
78 def ident(self) -> int | None: ...
79 daemon: bool
80 if sys.version_info >= (3, 14):
81 def __init__(
82 self,
83 group: None = None,
84 target: Callable[..., object] | None = None,
85 name: str | None = None,
86 args: Iterable[Any] = (),
87 kwargs: Mapping[str, Any] | None = None,
88 *,
89 daemon: bool | None = None,
90 context: Context | None = None,
91 ) -> None: ...
92 else:
93 def __init__(
94 self,
95 group: None = None,
96 target: Callable[..., object] | None = None,
97 name: str | None = None,
98 args: Iterable[Any] = (),
99 kwargs: Mapping[str, Any] | None = None,
100 *,
101 daemon: bool | None = None,
102 ) -> None: ...
103
104 def start(self) -> None: ...
105 def run(self) -> None: ...
106 def join(self, timeout: float | None = None) -> None: ...
107 @property
108 def native_id(self) -> int | None: ... # only available on some platforms
109 def is_alive(self) -> bool: ...
110 @deprecated("Deprecated since Python 3.10. Read the `daemon` attribute instead.")
111 def isDaemon(self) -> bool: ...
112 @deprecated("Deprecated since Python 3.10. Set the `daemon` attribute instead.")
113 def setDaemon(self, daemonic: bool) -> None: ...
114 @deprecated("Deprecated since Python 3.10. Read the `name` attribute instead.")
115 def getName(self) -> str: ...
116 @deprecated("Deprecated since Python 3.10. Set the `name` attribute instead.")
117 def setName(self, name: str) -> None: ...
118
119 class _DummyThread(Thread):
120 def __init__(self) -> None: ...
121
122 # This is actually the function _thread.allocate_lock for <= 3.12
123 Lock = _thread.LockType
124
125 # Python implementation of RLock.
126 @final
127 class _RLock:
128 _count: int
129 def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
130 def release(self) -> None: ...
131 __enter__ = acquire
132 def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
133
134 if sys.version_info >= (3, 14):
135 def locked(self) -> bool: ...
136
137 RLock = _thread.RLock # Actually a function at runtime.
138
139 class Condition:
140 def __init__(self, lock: Lock | _RLock | RLock | None = None) -> None: ...
141 def __enter__(self) -> bool: ...
142 def __exit__(
143 self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
144 ) -> None: ...
145 def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
146 def release(self) -> None: ...
147 if sys.version_info >= (3, 14):
148 def locked(self) -> bool: ...
149
150 def wait(self, timeout: float | None = None) -> bool: ...
151 def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ...
152 def notify(self, n: int = 1) -> None: ...
153 def notify_all(self) -> None: ...
154 @deprecated("Deprecated since Python 3.10. Use `notify_all()` instead.")
155 def notifyAll(self) -> None: ...
156
157 class Semaphore:
158 _value: int
159 def __init__(self, value: int = 1) -> None: ...
160 def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
161 def acquire(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
162 def __enter__(self, blocking: bool = True, timeout: float | None = None) -> bool: ...
163 def release(self, n: int = 1) -> None: ...
164
165 class BoundedSemaphore(Semaphore): ...
166
167 class Event:
168 def is_set(self) -> bool: ...
169 @deprecated("Deprecated since Python 3.10. Use `is_set()` instead.")
170 def isSet(self) -> bool: ...
171 def set(self) -> None: ...
172 def clear(self) -> None: ...
173 def wait(self, timeout: float | None = None) -> bool: ...
174
175 excepthook: Callable[[_ExceptHookArgs], object]
176 if sys.version_info >= (3, 10):
177 __excepthook__: Callable[[_ExceptHookArgs], object]
178 ExceptHookArgs = _ExceptHookArgs
179
180 class Timer(Thread):
181 args: Iterable[Any] # undocumented
182 finished: Event # undocumented
183 function: Callable[..., Any] # undocumented
184 interval: float # undocumented
185 kwargs: Mapping[str, Any] # undocumented
186
187 def __init__(
188 self,
189 interval: float,
190 function: Callable[..., object],
191 args: Iterable[Any] | None = None,
192 kwargs: Mapping[str, Any] | None = None,
193 ) -> None: ...
194 def cancel(self) -> None: ...
195
196 class Barrier:
197 @property
198 def parties(self) -> int: ...
199 @property
200 def n_waiting(self) -> int: ...
201 @property
202 def broken(self) -> bool: ...
203 def __init__(self, parties: int, action: Callable[[], None] | None = None, timeout: float | None = None) -> None: ...
204 def wait(self, timeout: float | None = None) -> int: ...
205 def reset(self) -> None: ...
206 def abort(self) -> None: ...
207
208 class BrokenBarrierError(RuntimeError): ...