Changing:
fi = sys.stdin if select.select([ sys.stdin, ], [], [], 0.0 )[ 0 ] else None
to
fi = sys.stdin if not sys.stdin.isatty() else None
seems to work reliably, so I will use that. It would still be nice to hear an explanation of what is going wrong with the select statement, however.