INNER CODE UNIT · Python

__del__

mostly-ai/mostlyai · mostlyai/sdk/_local/server.py:115

    def __del__(self):
        # Backup cleanup in case `stop` was not called explicitly or via context
        if self._server and self._server.started:
            print("Automatically shutting down server")
            self.stop()

    def register_exception_handlers(self):
        @self._app.exception_handler(Exception)
        async def global_exception_handler(request, exc):
            if isinstance(exc, ValidationError):
                return JSONResponse(status_code=422, content={"detail": str(exc)})
            # for fastapi.HTTPException: it will be raised as is
            # for other unhandled exceptions: client will receive a 500 Internal Server Error
            raise exc

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…