开发者

In subprocess.Popen, which file does bufsize apply to?

I'm in need of setting the stderr stream in a Popen call to line-buffered. I discovered the bufsize argument, but it doe开发者_运维百科sn't say which of the 3 (stdin, stdout, stderr) files it's actually applied to.

  • Which file does the bufsize argument modify?
  • How do I modify the other file buffering modes?


Use the source, Luke :-) /usr/lib/python2.7/subprocess.py:

if p2cwrite is not None:
    self.stdin = os.fdopen(p2cwrite, 'wb', bufsize)
if c2pread is not None:
    if universal_newlines:
        self.stdout = os.fdopen(c2pread, 'rU', bufsize)
    else:
        self.stdout = os.fdopen(c2pread, 'rb', bufsize)
if errread is not None:
    if universal_newlines:
        self.stderr = os.fdopen(errread, 'rU', bufsize)
    else:
        self.stderr = os.fdopen(errread, 'rb', bufsize)

So it seems it uses bufsize in all of them, no way to be specific.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜