title: Why does running a PowerShell script from Python seem to delay?
body: <p>When I launch a PowerShell script from Python, the delay seems to be approximately 45s, and I cannot figure out why.</p>
  
  <p>I'm trying to run a PowerShell script (accessing some APIs only available to PowerShell) from a Python script.</p>
  
  <p>I've tried a lot of permutations, and all incur ~45 second delay compared to just running the script from a command prompt, using an identical command line.</p>
  
  <p>For example - sample.ps1 might say:</p>
  
  <pre><code>echo foo
  </code></pre>
  
  <p>And runner.py might say:</p>
  
  <pre><code>import subprocess
  p = subprocess.Popen([POWERSHELL, '-File', 'sample.ps1'], stdout=subprocess.STDOUT)
  d = p.stdout.read()
  </code></pre>
  
  <p>Running the .ps1 script directly is fast, running it via runner.py (Python 2.7, 32bit on a 64bit machine) incurs 45 second delay.</p>
  
  <p>The exact same thing occurs if I use "os.system", or Twisted's built-in process tools. So I suspect it's some subtle interaction between the Python interpreter and the Powershell interpreter, possibly related to creation of console windows, or handling of stdin/out/err streams? (which I know don't "really exist" in the same way on Windows)</p>