Ihor Radchenko writes: > Peter Mao writes: > >> Expectation: When running ob-python code blocks, I should be able to >> kill the python session in the *Python* buffer and run another code >> block (or the same one). >> >> Problem: ob-python works fine on the first execution, but after >> `exit()`ing the python session, it hangs without executing the code. >> After a `C-g`, the prompt in the *Python* session shows up, but one then >> has to re-execute the code block, as none of it has run. > > Confirmed. > > It looks like `python-shell-first-prompt-hook' does not get triggered > in the described scenario with exit() and we enter infinite loop in the > code below. I think `python-shell-first-prompt-hook' is actually still triggered, but rather it is `org-babel-comint-wait-for-output' that is hanging while waiting for startup. However, we can just replace it with a `sleep-for' instead, because we now wait for `org-babel-python--initialized' anyways. See the attached patch. Please let me know if it fixes the problem for you.