On Sep 14, 2021, at 11:29 AM, Augusto Stoffel <arstoffel@gmail.com> wrote:

Hi Mark,

thanks for testing.

What happens if you start Emacs, then do 'M-x run-python', then 'M-x
rename-buffer' to rename the Python shell as '*python-chain*', and then
execute your notebook as usual?

If this works, then the problem is in how ob-python initializes the
shell.  The Python shell needs a fraction of a second to start up, and
if you send stuff to it before it's ready, it can be cause problems.

Augusto,

It runs as expected if I do that.

As a summary of what I have tried that works is:

- If I create the python buffer with this evaluation before running the org file/notebook.
(python-shell-make-comint "python" "python-chain" nil)

- If I don’t use the session header property to enable multiple src blocks to share the python session.

- If I revert back to the python.el on August 27th.
Possibly the older python.el was slow enough where I did not experience this problem.

Thanks for introducing me to the trace-function. I will try that with the org babel functions to see if I can learn something more about the initialization process.