|
1 | | -import sys |
2 | | -from _thread import _excepthook, _ExceptHookArgs |
| 1 | +from _threading_local import local as local |
3 | 2 | from _typeshed import ProfileFunction, TraceFunction |
4 | | -from collections.abc import Callable, Iterable, Mapping |
5 | | -from types import TracebackType |
6 | | -from typing import Any, TypeVar |
7 | | - |
8 | | -_T = TypeVar("_T") |
| 3 | +from threading import ( |
| 4 | + TIMEOUT_MAX as TIMEOUT_MAX, |
| 5 | + Barrier as Barrier, |
| 6 | + BoundedSemaphore as BoundedSemaphore, |
| 7 | + BrokenBarrierError as BrokenBarrierError, |
| 8 | + Condition as Condition, |
| 9 | + Event as Event, |
| 10 | + ExceptHookArgs as ExceptHookArgs, |
| 11 | + Lock as Lock, |
| 12 | + RLock as RLock, |
| 13 | + Semaphore as Semaphore, |
| 14 | + Thread as Thread, |
| 15 | + ThreadError as ThreadError, |
| 16 | + Timer as Timer, |
| 17 | + _DummyThread as _DummyThread, |
| 18 | + _RLock as _RLock, |
| 19 | + excepthook as excepthook, |
| 20 | +) |
9 | 21 |
|
10 | 22 | __all__ = [ |
11 | 23 | "get_ident", |
@@ -42,123 +54,3 @@ def main_thread() -> Thread: ... |
42 | 54 | def settrace(func: TraceFunction) -> None: ... |
43 | 55 | def setprofile(func: ProfileFunction | None) -> None: ... |
44 | 56 | def stack_size(size: int | None = None) -> int: ... |
45 | | - |
46 | | -TIMEOUT_MAX: float |
47 | | - |
48 | | -class ThreadError(Exception): ... |
49 | | - |
50 | | -class local: |
51 | | - def __getattribute__(self, name: str) -> Any: ... |
52 | | - def __setattr__(self, name: str, value: Any) -> None: ... |
53 | | - def __delattr__(self, name: str) -> None: ... |
54 | | - |
55 | | -class Thread: |
56 | | - name: str |
57 | | - daemon: bool |
58 | | - @property |
59 | | - def ident(self) -> int | None: ... |
60 | | - def __init__( |
61 | | - self, |
62 | | - group: None = None, |
63 | | - target: Callable[..., object] | None = None, |
64 | | - name: str | None = None, |
65 | | - args: Iterable[Any] = (), |
66 | | - kwargs: Mapping[str, Any] | None = None, |
67 | | - *, |
68 | | - daemon: bool | None = None, |
69 | | - ) -> None: ... |
70 | | - def start(self) -> None: ... |
71 | | - def run(self) -> None: ... |
72 | | - def join(self, timeout: float | None = None) -> None: ... |
73 | | - def getName(self) -> str: ... |
74 | | - def setName(self, name: str) -> None: ... |
75 | | - @property |
76 | | - def native_id(self) -> int | None: ... # only available on some platforms |
77 | | - def is_alive(self) -> bool: ... |
78 | | - if sys.version_info < (3, 9): |
79 | | - def isAlive(self) -> bool: ... |
80 | | - |
81 | | - def isDaemon(self) -> bool: ... |
82 | | - def setDaemon(self, daemonic: bool) -> None: ... |
83 | | - |
84 | | -class _DummyThread(Thread): ... |
85 | | - |
86 | | -class Lock: |
87 | | - def __enter__(self) -> bool: ... |
88 | | - def __exit__( |
89 | | - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None |
90 | | - ) -> bool | None: ... |
91 | | - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... |
92 | | - def release(self) -> None: ... |
93 | | - def locked(self) -> bool: ... |
94 | | - |
95 | | -class _RLock: |
96 | | - def __enter__(self) -> bool: ... |
97 | | - def __exit__( |
98 | | - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None |
99 | | - ) -> bool | None: ... |
100 | | - def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ... |
101 | | - def release(self) -> None: ... |
102 | | - |
103 | | -RLock = _RLock |
104 | | - |
105 | | -class Condition: |
106 | | - def __init__(self, lock: Lock | _RLock | None = None) -> None: ... |
107 | | - def __enter__(self) -> bool: ... |
108 | | - def __exit__( |
109 | | - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None |
110 | | - ) -> bool | None: ... |
111 | | - def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ... |
112 | | - def release(self) -> None: ... |
113 | | - def wait(self, timeout: float | None = None) -> bool: ... |
114 | | - def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ... |
115 | | - def notify(self, n: int = 1) -> None: ... |
116 | | - def notify_all(self) -> None: ... |
117 | | - def notifyAll(self) -> None: ... |
118 | | - |
119 | | -class Semaphore: |
120 | | - def __init__(self, value: int = 1) -> None: ... |
121 | | - def __exit__( |
122 | | - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None |
123 | | - ) -> bool | None: ... |
124 | | - def acquire(self, blocking: bool = True, timeout: float | None = None) -> bool: ... |
125 | | - def __enter__(self, blocking: bool = True, timeout: float | None = None) -> bool: ... |
126 | | - if sys.version_info >= (3, 9): |
127 | | - def release(self, n: int = ...) -> None: ... |
128 | | - else: |
129 | | - def release(self) -> None: ... |
130 | | - |
131 | | -class BoundedSemaphore(Semaphore): ... |
132 | | - |
133 | | -class Event: |
134 | | - def is_set(self) -> bool: ... |
135 | | - def set(self) -> None: ... |
136 | | - def clear(self) -> None: ... |
137 | | - def wait(self, timeout: float | None = None) -> bool: ... |
138 | | - |
139 | | -excepthook = _excepthook |
140 | | -ExceptHookArgs = _ExceptHookArgs |
141 | | - |
142 | | -class Timer(Thread): |
143 | | - def __init__( |
144 | | - self, |
145 | | - interval: float, |
146 | | - function: Callable[..., object], |
147 | | - args: Iterable[Any] | None = None, |
148 | | - kwargs: Mapping[str, Any] | None = None, |
149 | | - ) -> None: ... |
150 | | - def cancel(self) -> None: ... |
151 | | - |
152 | | -class Barrier: |
153 | | - @property |
154 | | - def parties(self) -> int: ... |
155 | | - @property |
156 | | - def n_waiting(self) -> int: ... |
157 | | - @property |
158 | | - def broken(self) -> bool: ... |
159 | | - def __init__(self, parties: int, action: Callable[[], None] | None = None, timeout: float | None = None) -> None: ... |
160 | | - def wait(self, timeout: float | None = None) -> int: ... |
161 | | - def reset(self) -> None: ... |
162 | | - def abort(self) -> None: ... |
163 | | - |
164 | | -class BrokenBarrierError(RuntimeError): ... |
0 commit comments