jupyter_console icon indicating copy to clipboard operation
jupyter_console copied to clipboard

real time live output from background ioloop

Open ppkwiatkowski opened this issue 5 years ago • 1 comments

Is it possible to show output from background ioloop process in real time and not only when prompting for it? It is a problem when using applications that are logging something.

minimal repro:

  1. Run import tornado; tornado.ioloop.PeriodicCallback(lambda: print("test output"), 2000).start() in jupyter-console.
  2. When I hit enter I get "test output" lines but they dont show up live.

ppkwiatkowski avatar Feb 21 '20 09:02 ppkwiatkowski

Btw. with async prompt-toolkit version >= 3.0.3 it was fairly easy to implement for my use-case by overwriting mainloop from ZMQTerminalInteractiveShell in my inherited shell class like that:

    async def handle_background_iopub(self):
        while self.keep_running:
            self.handle_iopub()
            await asyncio.sleep(1)

    def mainloop(self):
        asyncio.ensure_future(self.handle_background_iopub())
        super().mainloop()

but maybe it could be done better

ppkwiatkowski avatar Feb 28 '20 10:02 ppkwiatkowski