jupyter_console
jupyter_console copied to clipboard
real time live output from background ioloop
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:
- Run
import tornado; tornado.ioloop.PeriodicCallback(lambda: print("test output"), 2000).start()in jupyter-console. - 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