jupyter-c-kernel icon indicating copy to clipboard operation
jupyter-c-kernel copied to clipboard

Fix race condition which causes output to be lost sometimes

Open thomasjm opened this issue 5 years ago • 1 comments

There seems to be a race condition which can cause stdout/stderr output to be missed. I noticed this when a simple printf("Hello world\n") program would sometimes fail to print.

It happens when the final call to p.write_contents() happens in do_execute. At this time, the threads RealTimeSubprocess._stdout_thread and RealTimeSubprocess._stderr_thread may not have finished reading all the output.

To fix this, we call .join on both threads before the final p.write_contents().

thomasjm avatar Jun 21 '19 09:06 thomasjm

Thanks a lot! I took the liberty and integrated the commit into my branch of jupyter-c-kernel.

Fulguritus avatar Jun 29 '19 17:06 Fulguritus