title: How to clear stdout in Python subprocess?
body: <p>this snippet will ping an ip address in windows and get output line each 2 seconds, however, I found there's a very slowly memory increasement of ping.exe process after run it, if I deploy it to ping 1000 ip parallel, soon it will cause server hang, I think it may because of stdout buffer, may I know how to clear the stdout or limit its size? thanks!</p>
  
  <pre><code>...
  proc = subprocess.Popen(['c:\windows\system32\ping.exe','127.0.0.1', '-l', '10000', '-t'],stdout=subprocess.PIPE, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP) 
  
  while True: 
      time.sleep(2)
      os.kill(proc.pid, signal.CTRL_BREAK_EVENT) 
      line = proc.stdout.readline() 
  </code></pre>