-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Labels
technical-contextHelpful background informationHelpful background information
Description
This Server.handle_exit patch does not work with the latest uvicorn implementation (0.34.2):
sse-starlette/sse_starlette/sse.py
Lines 49 to 57 in d38d8f8
| try: | |
| from uvicorn.main import Server | |
| AppStatus.original_handler = Server.handle_exit | |
| Server.handle_exit = AppStatus.handle_exit # type: ignore | |
| except ImportError: | |
| logger.debug( | |
| "Uvicorn not installed. Graceful shutdown on server termination disabled." | |
| ) |
This is because the signal handlers are registered by uvicorn before the application module is imported:
async def serve(self, sockets: list[socket.socket] | None = None) -> None:
with self.capture_signals(): # <- Handlers set here
await self._serve(sockets)
async def _serve(self, sockets: list[socket.socket] | None = None) -> None:
process_id = os.getpid()
config = self.config
if not config.loaded:
config.load() # <- Application module imported hereSource here
I suspect that the app module used to be imported earlier and that it is no longer the case.
Metadata
Metadata
Assignees
Labels
technical-contextHelpful background informationHelpful background information