Async ipython-widgets/interaction

Hi,

I was wondering if the following is possible

Imagine I have a simulation running in a cell, which is taking some time, but it’s producing results while it’s going

At the same time, I would like to have an interactive that allows me to change parameters of the simulation while it’s still running, real-time.

I know this should be possible to do with async/coroutines stuff, but I tried a bit in the Jupyter Notebook and couldn’t get it work, and the built-in widgets also don’t seem to work on this way.

For concreteness, here’s an example

from IPython.display import display
def f(a, b):
    display(a + b)
    return a+b
w = interactive(f, a=10, b=20)
display(w)
import time
for i in arange(10):
        print(w.result)
        time.sleep(1)

and I would like to see the printed result change as you move the slider in the previous cell.

How possible would this be?