LineIterator.__next__ hangs forever if the last chunk of a streamed response has no trailing newline.
sagemaker-core/src/sagemaker/core/iterators.py:
except StopIteration:
if self.read_pos < self.buffer.getbuffer().nbytes:
continue
raise
continue re-reads the same unterminated line, fails the same check, calls next() on the now-exhausted byte_iterator again, gets StopIteration again, forever. Nothing in that branch changes read_pos or the buffer.
Repro:
from sagemaker.core.iterators import LineIterator
chunks = [
{"PayloadPart": {"Bytes": b'{"outputs": [" a"]}\n'}},
{"PayloadPart": {"Bytes": b'{"outputs": [" b"]}'}},
]
for line in LineIterator(iter(chunks)):
print(line)
Prints the first line then hangs.
Will open a PR.
LineIterator.__next__hangs forever if the last chunk of a streamed response has no trailing newline.sagemaker-core/src/sagemaker/core/iterators.py:continuere-reads the same unterminated line, fails the same check, callsnext()on the now-exhaustedbyte_iteratoragain, getsStopIterationagain, forever. Nothing in that branch changesread_posor the buffer.Repro:
Prints the first line then hangs.
Will open a PR.