fix: avoid flushing a missing capture stream when tracking URLs - #3453
Open
cpruijsen wants to merge 1 commit into
Open
fix: avoid flushing a missing capture stream when tracking URLs#3453cpruijsen wants to merge 1 commit into
cpruijsen wants to merge 1 commit into
Conversation
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.
Description
Stop the external-program tracking subprocess from calling
flush()on a missing capture file at EOF. The iterator sentinel is nowb""(binary PIPE EOF) instead of"", and flush runs only if a capture file exists.ExternalProgramTasktees stdout/stderr through a PIPE so it can scrape a tracking URL. Writes to the captureTemporaryFilewere already skipped whencapture_output=False. The empty-read branch still calledfile_to_write.flush(), which raisesAttributeError: 'NoneType' object has no attribute 'flush'in the child process. Spark tasks always enable this tracker, so the traceback shows up on yarn/spark-submit runs even though it does not change the task result.Fixes #3131
Decision: treat EOF as the end of the tracker and skip flush when there is no capture file.
Alternative: only guard the existing
flush()and leave the""sentinel / sleep loop.Why: the unguarded flush is what the issue reports, and the else branch only ran because
""never matchesb"". Can switch to the one-line guard if that is preferred.Motivation and Context
#3131
PySparkTaskon YARN logsfile_to_write.flush()onNonefrom_track_url_by_pattern. The reporter already noted it does not change the job result; the child exception is still noise on every tracked run without a capture file.Have you tested this? If so, how?
I have included unit tests.
test_tracking_process_exits_cleanly_when_capture_output_disabledfails without the source change (AssertionError: 1 != 0, child traceback is the issue'sAttributeError) and passes with it (exitcode == 0). Existing tracking tests intest/contrib/external_program_test.pyand the Spark client/cluster tracking tests still pass.