Getting realtime output using subprocess

前端 未结 18 2926
执笔经年
执笔经年 2020-11-22 10:12

I am trying to write a wrapper script for a command line program (svnadmin verify) that will display a nice progress indicator for the operation. This requires me to be abl

18条回答
  •  时光说笑
    2020-11-22 11:08

    I tried this, and for some reason while the code

    for line in p.stdout:
      ...
    

    buffers aggressively, the variant

    while True:
      line = p.stdout.readline()
      if not line: break
      ...
    

    does not. Apparently this is a known bug: http://bugs.python.org/issue3907 (The issue is now "Closed" as of Aug 29, 2018)

提交回复
热议问题