> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# supervisor

# `prefect_aws.microvm.supervisor`

Runs a flow run in a forked child process and reports the child's crashes.

## Functions

### `execute_flow_run` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect\_aws/microvm/supervisor.py#L43](https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect_aws/microvm/supervisor.py#L43)</sup>

```python theme={null}
execute_flow_run(payload: RunHookPayload) -> None
```

Run the flow run described by `payload` in the current process.

**Args:**

* `payload`: The flow run to execute. If it has an `entrypoint`, the flow is
  loaded from that entrypoint, relative to `working_dir` when one is
  given. Otherwise the flow is loaded from the flow run's deployment.

### `run_child` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect\_aws/microvm/supervisor.py#L77](https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect_aws/microvm/supervisor.py#L77)</sup>

```python theme={null}
run_child(payload: RunHookPayload) -> NoReturn
```

Run the flow run in a forked child process, then exit the process.

The exit code is 0 when the flow run finishes without raising and nonzero
otherwise.

**Args:**

* `payload`: The flow run to execute.

### `supervise_flow_run` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect\_aws/microvm/supervisor.py#L107](https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect_aws/microvm/supervisor.py#L107)</sup>

```python theme={null}
supervise_flow_run(payload: RunHookPayload) -> int
```

Run the flow run in a forked child and wait for the child to exit.

If the child exits nonzero or is killed by a signal, `Crashed` is proposed
for the flow run. SIGTERM sent to this process is forwarded to the child.
Call this from the main thread.

**Args:**

* `payload`: The flow run to execute.

**Returns:**

* The exit code for this process: 0 if the child exited 0, otherwise 1.

### `describe_child_exit` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect\_aws/microvm/supervisor.py#L169](https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect_aws/microvm/supervisor.py#L169)</sup>

```python theme={null}
describe_child_exit(wait_status: int) -> str | None
```

Describe how a child process ended, from its `os.waitpid` status.

**Args:**

* `wait_status`: The status returned by `os.waitpid`.

**Returns:**

* None if the child exited 0, otherwise a phrase such as
* `"was killed by signal 9"` or `"exited with code 1"`.

### `report_crash` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect\_aws/microvm/supervisor.py#L188](https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-aws/prefect_aws/microvm/supervisor.py#L188)</sup>

```python theme={null}
report_crash(flow_run_id: UUID, crash_reason: str) -> None
```

Propose `Crashed` for a flow run. A flow run in a final state keeps it.

**Args:**

* `flow_run_id`: The ID of the flow run.
* `crash_reason`: How the flow run's process ended, for the state message.
