Message245159
| Author |
martin.panter |
| Recipients |
BreamoreBoy, astrand, cvrebert, georg.brandl, giampaolo.rodola, ianbicking, josiahcarlson, martin.panter, rosslagerwall |
| Date |
2015年06月11日.08:18:48 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1434010730.13.0.837072664282.issue1260171@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
The non-blocking read and write features proposed in Issue 1191964 wouldn’t be sufficient. Perhaps they might be useful for implementing this feature on Windows though; I’m not sure. And a non-blocking write on Posix may be slightly more efficient as well, removing the limitation of copying in chunks of PIPE_BUF bytes.
Ian’s original patch posted here proposes a version of communicate() which accepts a file reader for the subprocess’s input, and file writers for the subprocess’s outputs. Another option could be something like my SubprocessWriter class <https://github.com/vadmium/pacman-tools/blob/9ffdd88/makeaur#L179>. It provides a file writer interface for the caller to write to the subprocess’s input, while copying data from the subprocess’s output behind the scenes. I used it to stream a tar file, as it is written by the "tarfile" module, into a GPG subprocess to create a digital signature, while writing the output of GPG into a BytesIO buffer. Using Unix command pipeline pseudocode, it is used a bit like this:
tarfile.open(mode="w|") | Popen("gpg") | BytesIO() |
|