def delete(self): """Shuts down running Jupyter server.""" r = shutdown_jupyter_server(self.connection_file) if r is None: return {'message': 'No running server'}, 404 # There no longer is a running server, so clean up the file. os.remove(self.connection_file) return {'message': 'Server shutdown was successful'}, 200
def delete(self): """Shuts down running Jupyter server.""" success = shutdown_jupyter_server(self.connection_file) if not success: return {"message": "No running server"}, 404 # There no longer is a running server, so clean up the file. os.remove(self.connection_file) return {"message": "Server shutdown was successful"}, 200
def shutdown(self) -> None: """Shuts down the launch. Additionally issues a DELETE request to the `jupyter-server` to have it shut down gracefully. Meaning that all its running kernels are shut down as well. """ # NOTE: this request will block the API. However, this is # desired as the front-end would otherwise need to poll whether # the Jupyter launch has been shut down (to be able to show its # status in the UI). # The request is blocking and returns after all kernels and # server have been shut down. IP = self.get_containers_IP() utils.shutdown_jupyter_server( f"http://{IP.jupyter_server}:8888{self._notebook_server_info['base_url']}/" ) return super().shutdown()
def client(): app = create_app(config_class=TestingConfig) with app.test_client() as client: # Yielding allows for teardown code. yield client # ---- Teardown code. ---- # Shutdown the Jupyter server and clear its connection file, if it is # still running. abs_path = os.path.dirname(os.path.abspath(__file__)) connection_file = os.path.join(abs_path, '../app/tmp/server_info.json') r = shutdown_jupyter_server(connection_file) if r is not None: os.remove(connection_file)