How to prevent BrokenPipeError when doing a flush in Python? How to prevent BrokenPipeError when doing a flush in Python? python-3.x python-3.x