These are chat archives for ipython/ipython

2nd
Oct 2018
john
@jcoady
Oct 02 2018 04:36
With asyncio in the notebook, will it be possible to have python code running in notebook cell for a long duration and while that code is running process messages from the front-end to the kernel. Currently you have to wait until the code in the cell runs to completion before retrieving messages from the front-end. Can you now put async code in the long running python code in a notebook cell to allow messages to be received from the front-end.
john
@jcoady
Oct 02 2018 20:04

Is kernel.do_one_iteration() broken in IPython 7.0 ? I have some code that doesn't work in IPython 7.0 but works in earlier versions of IPython. If I do the following loop the call to kernel.do_one_iteration() doesn't seem to work in IPYthon 7.0 .

import time
kernel = get_ipython().kernel

while True:
time.sleep(0.25)
kernel.do_one_iteration()
....

If I run this in a notebook cell it doesn't seem to do the same thing as earlier version of IPython.

In order to get it to work in IPython 7.0 I had to do this instead.

import asyncio
kernel = get_ipython().kernel

while True:
await asyncio.sleep(0.25)
kernel.do_one_iteration()
...

Why do I need to call await asyncio.sleep() to get kernel.do_one_iteration() to do what it does in earlier versions of IPython.