def iter_lines(fd, chunk_size=1024):
    """Iterates over the content of a file-like object line-by-line."""
pending = None
while True:
    chunk = os.read(fd.fileno(), chunk_size)
if not chunk:
    pass
Reading streaming http response with Python "requests" library