Make batch run --follow actually stream, and terminate#16
Merged
Conversation
--follow previously waited for the execution to finish and then printed its output in one block, which for a long job means staring at nothing for its whole duration. The first attempt at fixing that held a server-side follow open instead, and was worse: the server never closes a followed batch log, so the command hung until killed, and because it attached only after the execution left the queue it still showed everything at once. Tailing from a byte offset instead gives both properties. Output appears as it is produced -- verified against a job that prints every two seconds, and the lines arrive two seconds apart -- and the loop ends when the execution reaches a terminal state, which is where the answer to "is there more?" actually lives. The status is read before the log so a final read cannot miss anything written between the two. batch logs --follow uses the same loop, so it no longer hangs on an execution that has already finished.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--followpreviously waited for the execution to finish and printed its output in one block — for a long job, that means staring at nothing for its whole duration.My first attempt held a server-side follow open instead, and was worse: the server never closes a followed batch log, so the command hung until killed, and because it only attached after the execution left the queue it still showed everything at once. Measured, all nine lines of a 16-second job arrived simultaneously at +49s, then it hung.
Tailing from a byte offset gives both properties:
Lines arrive ~2s apart, matching the job's
sleep(2). The loop ends when the execution reaches a terminal state — where the answer to "is there more?" actually lives. The status is read before the log, so the final read can't miss anything written between the two.batch logs --followuses the same loop, so it no longer hangs on an already-finished execution.