While running my Python 2.7 scripts in Windows PowerShell I sometimes bumped into the problem that PowerShell would halt/pause execution of my scripts until I pressed a key. Initially I blamed it on myself and that I wrote some bad code but I couldn’t reproduce the problem. After careful analysis of my code I could find nothing that would request user input (like the raw_input() method) and also when I removed the threads the problem kept occurring. What could it be?
And then I found it: PowerShell has this very odd behavior that it will block all writes to the output if the user has selected text in the terminal. I would sometimes select text to be able to track how far the window was scrolling but didn’t know it would halt script execution!
If you see your PowerShell hacing “Select” as prefix of the window title make sure you press space to cancel select-mode or your scripts won’t run. Aargh!
I tested with my Mac to see if other terminals suffer the same feature. For the stock Terminal and iTerm I can confirm: they do not (obviously!).
Test Python script I used:
import time while True: print "A" time.sleep(2)
While running the script in PowerShell select some text by click-and-drag in the window. You will see that the script will stop executing.
Just putting this out there in case there is someone out there having the same problem.