Stopping Lumino Poll when JupyterLab server stops

Cheers @jtp for the pointers.

Actually I was looking at the wrong source code but my initial observations were still true. So, in services-extension, different component managers (like sessions, terminals, kernels,…) are being instantiated without standby callback and eventually ServiceManager with standy callback is being instantiated with the previously created instances of component managers. As the component managers are already instantiated, the passed standby callback is never used in component managers. A straight-forward fix is to use standby callback in all the component managers which should put all polls in standby when connection is lost. For instance, in the place of

const kernelManagerPlugin: ServiceManagerPlugin<Kernel.IManager> = {
  id: '@jupyterlab/services-extension:kernel-manager',
  description: 'The kernel manager plugin.',
  autoStart: true,
  provides: IKernelManager,
  optional: [IServerSettings],
  activate: (
    _: null,
    serverSettings: ServerConnection.ISettings | undefined
  ): Kernel.IManager => {
    return new KernelManager({ serverSettings });
  }
};

we use

const kernelManagerPlugin: ServiceManagerPlugin<Kernel.IManager> = {
  id: '@jupyterlab/services-extension:kernel-manager',
  description: 'The kernel manager plugin.',
  autoStart: true,
  provides: IKernelManager,
  optional: [IServerSettings, IConnectionStatus],
  activate: (
    _: null,
    serverSettings: ServerConnection.ISettings | undefined,
    connectionStatus: IConnectionStatus | undefined,
  ): Kernel.IManager => {
    return new KernelManager({ serverSettings,
      standby: () => {
        return !connectionStatus?.isConnected || 'when-hidden';
      } });
  }
};

If you think that makes sense, I can put up a PR.

Cheers!!

1 Like