Remove starting of a session and disposing it when connecting to remote Jupyter servers · Issue #8185 · microsoft/vscode-jupyter (original) (raw)

When connecting to remote jupyter servers we create sessions:

    // Try creating a session just to ensure we're connected. Callers of this function check to make sure jupyter
    // is running and connectable.
    const session = (await this.sessionManager.startNew(
        undefined,
        defaultKernel,
        launchInfo.connectionInfo.rootDirectory,
        cancelToken,
        launchInfo.disableUI
    )) as JupyterSession;
    const idleTimeout = this.configService.getSettings().jupyterLaunchTimeout;
    // The wait for idle should throw if we can't connect.
    await session.waitForIdle(idleTimeout);
    await session.dispose();

If we want to check if the jupyter server is running & connectable, why not use an API such as getting a list of the kernels.
This feels unnecessary.

E.g. if we cannot start the default kernel then we cannot connect at all (& we have a few issues where users connecting to remote servers cannot start the default kernel). I too ran into this a few months ago, admittedly its because my default python kernel was busted.

I think we can just remove this & test connectivity by simply calling the API to get a list of kernels/sessions or similar API.