What is the pipe-buffer deadlock with `Popen`?
AdvancedConceptOS, filesystem, subprocess & CLIs
Answer
OS pipes have a limited buffer (64 KiB on Linux). If you create both stdout=PIPE and stderr=PIPE and then call p.wait() or read only one pipe, the child blocks writing to the full pipe while you block waiting for it: neither progresses. Fixes: use p.communicate() (reads both concurrently), subprocess.run(capture_output=True) which uses communicate, merge stderr into stdout, or read pipes from separate threads. The subprocess docs warn about this explicitly for wait().
More on OS, filesystem, subprocess & CLIs
`os.path` vs `pathlib`: which do you use and why?BeginnerHow do you read environment variables safely?BeginnerHow do you walk a directory tree and find files?BeginnerWhat does `shutil` give you that `os` does not?BeginnerHow do you run an external command correctly with `subprocess`?BeginnerWhy is `shell=True` dangerous, and when is it acceptable?Intermediate