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

# stream

# `prefect.server.events.stream`

## Functions

### `subscribed` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L38](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L38)</sup>

```python theme={null}
subscribed(filter: EventFilter) -> AsyncGenerator['Queue[ReceivedEvent]', None]
```

### `events` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L54](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L54)</sup>

```python theme={null}
events(filter: EventFilter) -> AsyncGenerator[AsyncIterable[Optional[ReceivedEvent]], None]
```

### `distributor` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L81](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L81)</sup>

```python theme={null}
distributor() -> AsyncGenerator[messaging.MessageHandler, None]
```

### `start_distributor` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L109](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L109)</sup>

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

Starts the distributor consumer as a global background task

### `stop_distributor` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L121](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L121)</sup>

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

Stops the distributor consumer global background task

### `run_distributor` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L168](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L168)</sup>

```python theme={null}
run_distributor(started: asyncio.Event) -> NoReturn
```

Runs the distributor consumer forever until it is cancelled

## Classes

### `Distributor` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L139](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L139)</sup>

**Methods:**

#### `all_services` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L69](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L69)</sup>

```python theme={null}
all_services(cls) -> Sequence[type[Self]]
```

Get list of all service classes

#### `enabled` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L151](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L151)</sup>

```python theme={null}
enabled(cls) -> bool
```

#### `enabled` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L64](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L64)</sup>

```python theme={null}
enabled(cls) -> bool
```

Whether the service is enabled

#### `enabled_services` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L83](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L83)</sup>

```python theme={null}
enabled_services(cls) -> list[type[Self]]
```

Get list of enabled service classes

#### `environment_variable_name` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L147](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L147)</sup>

```python theme={null}
environment_variable_name(cls) -> dict[str, str]
```

#### `environment_variable_name` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L60](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L60)</sup>

```python theme={null}
environment_variable_name(cls) -> str
```

#### `run_services` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L104](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L104)</sup>

```python theme={null}
run_services(cls) -> NoReturn
```

Run enabled services until cancelled.

#### `running` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L89](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L89)</sup>

```python theme={null}
running(cls) -> AsyncGenerator[None, None]
```

A context manager that runs enabled services on entry and stops them on
exit.

#### `service_settings` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L143](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L143)</sup>

```python theme={null}
service_settings(cls) -> ServicesBaseSetting
```

#### `service_settings` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L55](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L55)</sup>

```python theme={null}
service_settings(cls) -> ServicesBaseSetting
```

The Prefect setting that controls whether the service is enabled

#### `start` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L154](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L154)</sup>

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

#### `start` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L114](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L114)</sup>

```python theme={null}
start(self) -> NoReturn
```

Start running the service, which may run indefinitely

#### `stop` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L164](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/events/stream.py#L164)</sup>

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

#### `stop` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L119](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/services/base.py#L119)</sup>

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

Stop the service
