from IPython.html.widgets import interact x = True while True: x = not x get_ipython().kernel.do_one_iteration() x from IPython.display import display, clear_output import time dy = 0.0 y = 0.0 while True: y += dy * 0.1 clear_output() display(y) get_ipython().kernel.do_one_iteration() time.sleep(0.1) @interact def foo(arg=1): global dy dy = arg a, b = 0, 0 while True: b = a % 10 get_ipython().kernel.do_one_iteration() while True: a += 1 get_ipython().kernel.do_one_iteration() clear_output() display(b) time.sleep(0.05) # Not strictly necessary, but try to keep load down active = set() def parallel(coroutine): """ Mark a function for parallel execution. Works as a decorator, too """ active.add(coroutine()) return coroutine def remove_all(): active.clear() while True: for act in active: next(act) get_ipython().kernel.do_one_iteration() time.sleep(0.05) a, b = 0, 0 def foo(): global a, b while True: b = a % 10 yield parallel(foo) @parallel def bar(): global a, b while True: a += 1 clear_output() display(b) yield