Skip to content

Commit 22c1e0e

Browse files
authored
Merge pull request #22332 from mvdbeek/fix_readline_to_advance_iterator_25.1
[25.1] Discard rest of line in chunks in iter_start_of_line
2 parents 1ea3db2 + 3358f8f commit 22c1e0e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/galaxy/util/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,11 @@ def iter_start_of_line(fh, chunk_size=None):
323323
if not data:
324324
break
325325
if not data.endswith("\n"):
326-
# Discard the rest of the line
327-
fh.readline()
326+
# Discard the rest of the line without reading it all into memory
327+
while True:
328+
line_rest = fh.readline(CHUNK_SIZE)
329+
if not line_rest or line_rest.endswith("\n"):
330+
break
328331
yield data
329332

330333

0 commit comments

Comments
 (0)