jupyter / jupyter_console

Jupyter Terminal Console

Home Page:http://jupyter-console.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

real time live output from background ioloop

ppkwiatkowski opened this issue · 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.

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