cylc-uiserver icon indicating copy to clipboard operation
cylc-uiserver copied to clipboard

hub-stopped server not calling stop_extension

Open dwsutherland opened this issue 2 years ago • 6 comments

The UIS stop extension: https://github.com/cylc/cylc-uiserver/blob/da038f00a1c9d6fb6bbf5b2a156bbc4fc7b299a7/cylc/uiserver/app.py#L516-L524

Runs when stopping (keyboard interrupt) the hubless server (cylc gui), however, it isn't run when stopping the server via the hub..

From it's contents I assume it should be run with both forms of stop

I found this while trying to clean up api_tokens for the coming cli-via-uis:

    async def stop_extension(self):
        # Remove API token if hub spawned
        self.log.info(f'HELLO THERE!')
        print('HELLO!')
        if os.environ.get("JUPYTERHUB_API_TOKEN"):
            print('HUB SPAWNED')
        else:
            print(os.environ)
        try:
            os.unlink(API_TOKEN_FILE)
        except FileNotFoundError:
            pass
        # stop the async scan task
        await self.workflows_mgr.stop()
        for sub in self.data_store_mgr.w_subs.values():
            sub.stop()
        # Shutdown the thread pool executor
        self.data_store_mgr.executor.shutdown(wait=False)
        # Destroy ZeroMQ context of all sockets
        self.workflows_mgr.context.destroy()

The cylc gui stoppage removed the api_token: image where the cylc hub server stop: image

didn't: image

Pull requests welcome! This is an Open Source project - please consider contributing a bug fix yourself (please read CONTRIBUTING.md before starting any work though).

dwsutherland avatar Oct 20 '22 04:10 dwsutherland