PtyManagerProtocol
Sub classes¶
| Name | Children | Inherits |
|---|---|---|
| SpawnPtyManager exxec.spawn_pty_manager PTY sessions for any environment implementing `spawn(pty\=...)`. |
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| Protocol typing Base class for protocol classes. |
|
â‹” Inheritance diagram¶
graph TD
3356615053["pty_manager.PtyManagerProtocol"]
1073422405["typing.Protocol"]
3481597255["typing.Generic"]
2751680898["builtins.object"]
1073422405 --> 3356615053
3481597255 --> 1073422405
2751680898 --> 3481597255
🛈 DocStrings¶
Bases: Protocol
Protocol for managing PTY (pseudo-terminal) sessions.
This protocol defines the interface that all PTY managers must implement, allowing interactive terminal sessions across different execution environments.
Implementations
- SpawnPtyManager: Any environment with
supports_pty
Source code in src/exxec/pty_manager.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
create
async
¶
create(
size: PtySize | None = None,
command: str | None = None,
args: list[str] | None = None,
cwd: str | None = None,
env: dict[str, str] | None = None,
) -> PtyInfo
Create a new PTY session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
PtySize | None
|
Initial terminal size (defaults to 24x80) |
None
|
command
|
str | None
|
Shell command to run (defaults to user's shell or /bin/bash) |
None
|
args
|
list[str] | None
|
Arguments for the command |
None
|
cwd
|
str | None
|
Working directory |
None
|
env
|
dict[str, str] | None
|
Environment variables |
None
|
Returns:
| Type | Description |
|---|---|
PtyInfo
|
PtyInfo with session details including the PTY ID |
Source code in src/exxec/pty_manager.py
get_info
async
¶
get_info(pty_id: str) -> PtyInfo | None
Get information about a PTY session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pty_id
|
str
|
The PTY session ID |
required |
Returns:
| Type | Description |
|---|---|
PtyInfo | None
|
PtyInfo if found, None otherwise |
kill
async
¶
Kill a PTY session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pty_id
|
str
|
The PTY session ID |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if killed successfully, False if not found |
list_sessions
async
¶
list_sessions() -> list[PtyInfo]
List all active PTY sessions.
Returns:
| Type | Description |
|---|---|
list[PtyInfo]
|
List of PtyInfo for all active sessions |
read
async
¶
Read data from a PTY's stdout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pty_id
|
str
|
The PTY session ID |
required |
size
|
int
|
Maximum bytes to read |
4096
|
Returns:
| Type | Description |
|---|---|
bytes
|
Output data from the PTY |
resize
async
¶
resize(pty_id: str, size: PtySize) -> None
Resize a PTY session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pty_id
|
str
|
The PTY session ID |
required |
size
|
PtySize
|
New terminal size |
required |
stream
¶
Stream output from a PTY session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pty_id
|
str
|
The PTY session ID |
required |
Yields:
| Type | Description |
|---|---|
AsyncIterator[bytes]
|
Chunks of output data as they become available |
write
async
¶
Write data to a PTY's stdin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pty_id
|
str
|
The PTY session ID |
required |
data
|
bytes
|
Data to write (typically user input) |
required |