Run the server and set up restart capability. Args: sockets: Optional list of sockets to bind to.
(self, sockets: list[socket] | None = None)
| 489 | return URL(f'{protocol}://{self.config.host}:{self.config.port}/') |
| 490 | |
| 491 | async def serve(self, sockets: list[socket] | None = None) -> None: |
| 492 | """Run the server and set up restart capability. |
| 493 | |
| 494 | Args: |
| 495 | sockets: Optional list of sockets to bind to. |
| 496 | """ |
| 497 | self.restart_requested = asyncio.Event() |
| 498 | |
| 499 | loop = asyncio.get_event_loop() |
| 500 | tasks = { |
| 501 | loop.create_task(super().serve(sockets=sockets)), |
| 502 | loop.create_task(self.watch_restarts()), |
| 503 | } |
| 504 | await asyncio.wait(tasks) |
| 505 | |
| 506 | async def restart(self) -> None: |
| 507 | """Request server restart and wait for it to complete. |