Source: https://h2corn.monicz.dev/api/lifespan/

# Lifespan scope and messages

Use these mappings for application startup and shutdown events in the ASGI lifespan protocol.

## LifespanScope

Bases: `TypedDict`

A lifespan scope in [`Scope`](https://h2corn.monicz.dev/api/applications/#h2corn.Scope "Scope module-attribute").

### type`instance-attribute`

```python
type: Literal['lifespan']
```

### asgi`instance-attribute`

```python
asgi: LifespanASGIVersions
```

### state`instance-attribute`

```python
state: State
```

## LifespanStartup

Bases: `TypedDict`

A lifespan startup event in [`ReceiveMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.ReceiveMessage "ReceiveMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['lifespan.startup']
```

## LifespanShutdown

Bases: `TypedDict`

A lifespan shutdown event in [`ReceiveMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.ReceiveMessage "ReceiveMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['lifespan.shutdown']
```

## LifespanStartupComplete

Bases: `TypedDict`

A lifespan startup-complete event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['lifespan.startup.complete']
```

## LifespanStartupFailed

Bases: `TypedDict`

A lifespan startup-failed event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['lifespan.startup.failed']
```

### message`instance-attribute`

```python
message: NotRequired[str]
```

## LifespanShutdownComplete

Bases: `TypedDict`

A lifespan shutdown-complete event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['lifespan.shutdown.complete']
```

## LifespanShutdownFailed

Bases: `TypedDict`

A lifespan shutdown-failed event in [`SendMessage`](https://h2corn.monicz.dev/api/applications/#h2corn.SendMessage "SendMessage module-attribute").

### type`instance-attribute`

```python
type: Literal['lifespan.shutdown.failed']
```

### message`instance-attribute`

```python
message: NotRequired[str]
```
