redirect sys.stdout to specific Jupyter Notebook cell
The documentation for ipywidgets.Output has a section about interacting with output widgets from background threads. Using the Output.append_stdout method there is no need for locking. The final cell in this answer can then be replaced with: def t1_main(): for i in range(10): output1.append_stdout(f’thread1 {i}\n’) time.sleep(0.5) def t2_main(): for i in range(10): output2.append_stdout(f’thread2 {i}\n’) time.sleep(0.5) output1.clear_output() … Read more