Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/anyio/abc/_subprocesses.py: 100%
29 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:12 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:12 +0000
1from abc import abstractmethod
2from signal import Signals
3from typing import Optional
5from ._resources import AsyncResource
6from ._streams import ByteReceiveStream, ByteSendStream
9class Process(AsyncResource):
10 """An asynchronous version of :class:`subprocess.Popen`."""
12 @abstractmethod
13 async def wait(self) -> int:
14 """
15 Wait until the process exits.
17 :return: the exit code of the process
18 """
20 @abstractmethod
21 def terminate(self) -> None:
22 """
23 Terminates the process, gracefully if possible.
25 On Windows, this calls ``TerminateProcess()``.
26 On POSIX systems, this sends ``SIGTERM`` to the process.
28 .. seealso:: :meth:`subprocess.Popen.terminate`
29 """
31 @abstractmethod
32 def kill(self) -> None:
33 """
34 Kills the process.
36 On Windows, this calls ``TerminateProcess()``.
37 On POSIX systems, this sends ``SIGKILL`` to the process.
39 .. seealso:: :meth:`subprocess.Popen.kill`
40 """
42 @abstractmethod
43 def send_signal(self, signal: Signals) -> None:
44 """
45 Send a signal to the subprocess.
47 .. seealso:: :meth:`subprocess.Popen.send_signal`
49 :param signal: the signal number (e.g. :data:`signal.SIGHUP`)
50 """
52 @property
53 @abstractmethod
54 def pid(self) -> int:
55 """The process ID of the process."""
57 @property
58 @abstractmethod
59 def returncode(self) -> Optional[int]:
60 """
61 The return code of the process. If the process has not yet terminated, this will be
62 ``None``.
63 """
65 @property
66 @abstractmethod
67 def stdin(self) -> Optional[ByteSendStream]:
68 """The stream for the standard input of the process."""
70 @property
71 @abstractmethod
72 def stdout(self) -> Optional[ByteReceiveStream]:
73 """The stream for the standard output of the process."""
75 @property
76 @abstractmethod
77 def stderr(self) -> Optional[ByteReceiveStream]:
78 """The stream for the standard error output of the process."""