jupyter-c-kernel
jupyter-c-kernel copied to clipboard
Fix race condition which causes output to be lost sometimes
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()
.
Thanks a lot! I took the liberty and integrated the commit into my branch of jupyter-c-kernel.