[python] How to prevent errno 32 broken pipe?