[IPython-dev] Output from background threads in notebook?

Doug Blank doug.blank at gmail.com
Sun Mar 16 21:30:26 EDT 2014


If you run the following cell:

import threading
import time
class ThreadClass(threading.Thread):
    def run(self):
        x = 1
        while True:
            print(x)
            x += 1
            time.sleep(1)
t = ThreadClass()
t.start()
t.join()

Then you will see the data for as long as you don't interrupt the
cell. If you comment out the t.join(), then you won't see any output
(or maybe just the first printed).

In the next cell, if you do something such as, say:

while True:
    pass

and then interrupt the kernel, you'll see some more of the printouts.

It appears that when the execution_reply is received, the notebook
doesn't take output messages anymore. Is this all by design? Is there
a manner to make sure background-running output can still make its way
to the notebook?

-Doug



More information about the IPython-dev mailing list