jason810496 commented on code in PR #49470:
URL: https://github.com/apache/airflow/pull/49470#discussion_r2160351240
##########
airflow-core/src/airflow/utils/log/file_task_handler.py:
##########
@@ -423,12 +649,23 @@ def _read(
TaskInstanceState.RUNNING,
TaskInstanceState.DEFERRED,
)
- if metadata and "log_pos" in metadata:
- previous_line = metadata["log_pos"]
- logs = logs[previous_line:] # Cut off previously passed log test
as new tail
- else:
- logs = header + logs
- return logs, {"end_of_log": end_of_log, "log_pos": log_pos}
+
+ with LogStreamAccumulator(out_stream, HEAP_DUMP_SIZE) as
stream_accumulator:
+ log_pos = stream_accumulator.total_lines
+ out_stream = stream_accumulator.stream
+
+ # skip log stream until the last position
+ if metadata and "log_pos" in metadata:
+ for _ in range(metadata["log_pos"]):
+ next(out_stream, None)
Review Comment:
Yes, we can use `islice` here as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]