# nodus.process

> Processes and files inside a running Job, Sandbox or Workspace (resources.md §3.6).

Source: https://nodus-platform-site.pages.dev/docs/reference/python/nodus-process/
Build revision: 211ad9f836655b1c3a2668c4693e442471f28614

<!-- Generated by scripts/gen-reference.mjs from the SDK docstrings (griffe). Do not edit: run make gen. -->

Processes and files inside a running Job, Sandbox or Workspace (resources.md §3.6).

`stdout`, `stderr` and `stdin` use the long-poll protocol (`output`, `stdin`, `signals`), which needs no WebSocket and works through every proxy; a Process’s output is retained, so a reader that reconnects resumes from its offset. `p.attach()` opens the interactive remotecommand v5 WebSocket session instead, for terminals.

## `Attach`

```python
class Attach(ws: Any) -> None
```

Frames of a remotecommand v5 session: iterate for `(stream, bytes)`; `write`, `resize`, `close_stdin`.

### `Attach.close_stdin`

```python
close_stdin() -> None
```

### `Attach.exit_code`

Type: `int | None`

Set once the session reports the process’s exit status.

### `Attach.resize`

```python
resize(rows: int, cols: int) -> None
```

### `Attach.write`

```python
write(data: bytes | str) -> None
```

## `File`

```python
class File(files: _Files, path: str, mode: str) -> None
```

A file opened with `sb.open(path, mode)`: reads come from one download, writes upload on `close()`.

### `File.close`

```python
close() -> None
```

### `File.read`

```python
read(n: int = 1) -> str | bytes
```

### `File.write`

```python
write(data: str | bytes) -> int
```

## `Files`

```python
class Files(client: Client, kind: str, name: str, project: str | None = None) -> None
```

The `files` subresource of a Job, Sandbox or Workspace.

### `Files.list`

```python
list(path: str = '/') -> list[Obj]
```

### `Files.open`

```python
open(path: str, mode: str = 'r') -> _File
```

### `Files.read`

```python
read(path: str) -> bytes
```

### `Files.remove`

```python
remove(path: str) -> None
```

### `Files.write`

```python
write(path: str, data: bytes | str, expected_sha256: str | None = None) -> None
```

## `Process`

```python
class Process(client: Client, obj: Obj) -> None
```

One command executing in a running attempt: `stdout`, `stderr`, `stdin`, `wait()`, `returncode`.

### `Process.attach`

```python
attach(stdin: bool = True, tty: bool = False) -> AsyncIterator[_Attach]
```

An interactive session over the remotecommand v5 WebSocket (one stdin writer; many readers).

### `Process.cancel`

```python
cancel() -> None
```

### `Process.name`

Type: `str`

### `Process.resize`

```python
resize(rows: int, cols: int) -> None
```

### `Process.returncode`

Type: `int | None`

The exit code once the process has finished, else None.

### `Process.signal`

```python
signal(sig: str) -> None
```

Send `SIGINT`, `SIGTERM`, `SIGKILL`, `SIGHUP`, `SIGQUIT`, `SIGUSR1` or `SIGUSR2`.

### `Process.start`

```python
start(client: Client, kind: str, parent: str, command: list[str], *, tty: bool = False, stdin: bool = False, env: dict[str, str] | None = None, workdir: str | None = None, timeout: str | None = None, project: str | None = None, **params: Any) -> _Process
```

### `Process.stderr`

Type: `_StreamReader`

### `Process.stdin`

Type: `_StdinWriter`

### `Process.stdout`

Type: `_StreamReader`

### `Process.wait`

```python
wait(timeout: float | None = None) -> int
```

Block until the process exits and return its exit code; `TimeoutError` after `timeout` seconds.

### `Process.write`

```python
write(data: bytes | str) -> None
```

## `StdinWriter`

```python
class StdinWriter(proc: _Process) -> None
```

### `StdinWriter.drain`

```python
drain() -> None
```

Writes are sent as they are made, so there is nothing buffered to flush.

### `StdinWriter.write`

```python
write(data: bytes | str) -> None
```

### `StdinWriter.write_eof`

```python
write_eof() -> None
```

## `StreamReader`

```python
class StreamReader(proc: _Process, stream: str) -> None
```

stdout or stderr of a Process: `read()` returns everything; iterating yields text as it arrives.

### `StreamReader.read`

```python
read() -> str
```

### `StreamReader.read_bytes`

```python
read_bytes() -> bytes
```
