Is there an recommended way to pipe stdin from a string object to a spawned process using subprocess module? For pipes, the documentation recommends using the
- Code: Select all
But the communicate() waits for the process to finish, while I need the process to persist.Use communicate() rather than .stdin.write, .stdout.read or .stderr.read to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking the child process.
I recognize that one can write a subclass of Popen and override the communicate() method, replacing the call to wait() therein with a call to poll(). But that seems excessive, and I'm prone to introducing unforeseen errors.