4 ms·
Yes, stdin.write, stdout.read and stderr.read can cause deadlocks if not used carefully. However, those operations are rarely needed and are complicated in Bash
by lalaland1125 7y ago
Yes, stdin.write, stdout.read and stderr.read can cause deadlocks if not used carefully. However, those operations are rarely needed and are complicated in Bash as well (usually requiring sub-shells, etc). 99% of Bash scripts can be written without using those operations (you simply pipe input/output from one program to the next rather than trying to manually forward it in your program).
This is actually one of the main advantages of using Python. You can solve all those deadlock issues through careful use of threads, which are much better than the Bash sub-shell equivalent.
If anyone has an example script that requires the use of those functions and is cumbersome in Python, please share it. We can always improve the Python standard library if necessary.