INNER CODE UNIT · Python

__enter__

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

    def __enter__(self):
        # Ensure the server is running
        self.start()
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        # Stop the server when exiting the context
        self.stop()

    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):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…