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

# server

# `prefect_aws.microvm.server`

HTTP server for the AWS Lambda MicroVM lifecycle hooks.

## Classes

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

Serves the MicroVM lifecycle hooks and hands the first valid `/run` request
to the thread that calls `wait_for_run_request`.

Hooks are accepted both at `/<hook>` and at
`/aws/lambda-microvms/runtime/v1/<hook>`.

**Methods:**

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

```python theme={null}
claim_run(self) -> bool
```

Return True for the first `/run` request and False for every later one.

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

```python theme={null}
process_request(self, request: Any, client_address: Any) -> None
```

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

```python theme={null}
process_request_thread(self, request: Any, client_address: Any) -> None
```

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

```python theme={null}
server_bind(self) -> None
```

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

```python theme={null}
stop_serving(self, timeout: float = HANDLER_FINISH_TIMEOUT_SECONDS) -> None
```

Stop accepting hook requests and wait up to `timeout` seconds for the
requests in progress to finish, so that no handler thread holds a lock
when the process forks. Requests still in progress after `timeout` are
logged and left running.

**Args:**

* `timeout`: The longest time to wait for requests in progress, in seconds.

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

```python theme={null}
submit_run(self, request: RunHookRequest | InvalidRunHookPayload) -> None
```

Pass a parsed `/run` request, or the reason it was rejected, to `wait_for_run_request`.

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

```python theme={null}
wait_for_run_request(self) -> RunHookRequest | InvalidRunHookPayload
```

Block until the first `/run` request has been answered, then return it.

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

Request handler for `LifecycleHookServer`.

**Methods:**

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

```python theme={null}
do_GET(self) -> None
```

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

```python theme={null}
do_POST(self) -> None
```

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

```python theme={null}
log_message(self, format: str, *args: Any) -> None
```
