python stdin flush broken pipe