|
11 | 11 |
|
12 | 12 | import trio |
13 | 13 |
|
14 | | -from ._abc import AsyncResource, ReceiveStream, SendStream |
15 | 14 | from ._core import ClosedResourceError, TaskStatus |
16 | | -from ._deprecate import deprecated |
17 | 15 | from ._highlevel_generic import StapledStream |
18 | 16 | from ._subprocess_platform import ( |
19 | 17 | create_pipe_from_child_output, |
|
28 | 26 | from collections.abc import Awaitable, Callable, Mapping, Sequence |
29 | 27 | from io import TextIOWrapper |
30 | 28 |
|
31 | | - from typing_extensions import Self, TypeAlias |
| 29 | + from typing_extensions import TypeAlias |
| 30 | + |
| 31 | + from ._abc import ReceiveStream, SendStream |
32 | 32 |
|
33 | 33 |
|
34 | 34 | # Sphinx cannot parse the stringified version |
@@ -101,7 +101,7 @@ def fileno(self) -> int: |
101 | 101 |
|
102 | 102 |
|
103 | 103 | @final |
104 | | -class Process(AsyncResource, metaclass=NoPublicConstructor): |
| 104 | +class Process(metaclass=NoPublicConstructor): |
105 | 105 | r"""A child process. Like :class:`subprocess.Popen`, but async. |
106 | 106 |
|
107 | 107 | This class has no public constructor. The most common way to get a |
@@ -223,41 +223,6 @@ def returncode(self) -> int | None: |
223 | 223 | self._close_pidfd() |
224 | 224 | return result |
225 | 225 |
|
226 | | - @deprecated( |
227 | | - "0.20.0", |
228 | | - thing="using trio.Process as an async context manager", |
229 | | - issue=1104, |
230 | | - instead="run_process or nursery.start(run_process, ...)", |
231 | | - ) |
232 | | - async def __aenter__(self) -> Self: |
233 | | - return self |
234 | | - |
235 | | - # Type ignore is for `Type of decorated function contains type "Any" ("Callable[[Process], Coroutine[Any, Any, None]]")` |
236 | | - @deprecated( |
237 | | - "0.20.0", issue=1104, instead="run_process or nursery.start(run_process, ...)" |
238 | | - ) |
239 | | - async def aclose(self) -> None: # type: ignore[misc] |
240 | | - """Close any pipes we have to the process (both input and output) |
241 | | - and wait for it to exit. |
242 | | -
|
243 | | - If cancelled, kills the process and waits for it to finish |
244 | | - exiting before propagating the cancellation. |
245 | | - """ |
246 | | - with trio.CancelScope(shield=True): |
247 | | - if self.stdin is not None: |
248 | | - await self.stdin.aclose() |
249 | | - if self.stdout is not None: |
250 | | - await self.stdout.aclose() |
251 | | - if self.stderr is not None: |
252 | | - await self.stderr.aclose() |
253 | | - try: |
254 | | - await self.wait() |
255 | | - finally: |
256 | | - if self._proc.returncode is None: |
257 | | - self.kill() |
258 | | - with trio.CancelScope(shield=True): |
259 | | - await self.wait() |
260 | | - |
261 | 226 | def _close_pidfd(self) -> None: |
262 | 227 | if self._pidfd is not None: |
263 | 228 | trio.lowlevel.notify_closing(self._pidfd.fileno()) |
|
0 commit comments