Skip to content

Instantly share code, notes, and snippets.

View OptimusT's full-sized avatar

Michael Ma OptimusT

  • Shanghai Jiao Tong University
  • Shanghai
View GitHub Profile
@OptimusT
OptimusT / subprocess-bufsize-test.py
Created August 12, 2021 15:32 — forked from jaypei/subprocess-bufsize-test.py
使用subprocess。避免在子程序大量输出时因buffer size满,导致父进程hang住。
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
from StringIO import StringIO
out = StringIO()
sp = subprocess.Popen(["python", "test_output.py"],
stdout=subprocess.PIPE,