Drive ``dispatcher`` until the underlying channel closes. The loop-mode driver: builds the kernel, hands `on_request`/`on_notify` to `dispatcher.run()`, and tears down `connection.exit_stack` (shielded) on the way out. The entry constructs the `Connection`; this only consumes it.
(
server: Server[LifespanT],
dispatcher: Dispatcher[Any],
*,
connection: Connection,
lifespan_state: LifespanT,
init_options: InitializationOptions | None = None,
task_status: anyio.abc.TaskStatus[None] = anyio.TASK_STATUS_IGNORED,
)
| 415 | |
| 416 | |
| 417 | async def serve_connection( |
| 418 | server: Server[LifespanT], |
| 419 | dispatcher: Dispatcher[Any], |
| 420 | *, |
| 421 | connection: Connection, |
| 422 | lifespan_state: LifespanT, |
| 423 | init_options: InitializationOptions | None = None, |
| 424 | task_status: anyio.abc.TaskStatus[None] = anyio.TASK_STATUS_IGNORED, |
| 425 | ) -> None: |
| 426 | """Drive ``dispatcher`` until the underlying channel closes. |
| 427 | |
| 428 | The loop-mode driver: builds the kernel, hands `on_request`/`on_notify` |
| 429 | to `dispatcher.run()`, and tears down `connection.exit_stack` (shielded) |
| 430 | on the way out. The entry constructs the `Connection`; this only consumes |
| 431 | it. |
| 432 | """ |
| 433 | runner = ServerRunner(server, connection, lifespan_state, init_options=init_options) |
| 434 | try: |
| 435 | await dispatcher.run(runner.on_request, runner.on_notify, task_status=task_status) |
| 436 | finally: |
| 437 | await aclose_shielded(connection) |
| 438 | |
| 439 | |
| 440 | async def serve_loop( |
no test coverage detected