HTTP#close waits for the threads it kills - #49
Merged
Merged
Conversation
The example slept 0.1 s after close and was still flaky on TruffleRuby, because Thread#kill only asks the thread to stop. Without the sleeps it fails on every run: close returns while the threads are still winding down. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Thread#kill only asks a thread to stop, so close returned while the flush and request threads were still winding down, which made the close example flaky on TruffleRuby. Joining them makes close return once they are gone, which is what its at_exit caller should get. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Logtail::LogDevices::HTTP#close should kill the threadsfailed on TruffleRuby in https://github.com/logtail/logtail-ruby/actions/runs/36743953257/job/109985245554 with the flush thread stillalive?and "aborting".closeonly callsThread#kill, which asks the threads to stop and returns at once, so the example slept 0.1 s and hoped for the best (its own comment: "too fast!").The first commit only removes the sleeps and is expected to fail on every job: on Ruby 3.4 it fails 30 out of 30 runs locally. The second commit makes
closejoin the threads it kills, so it returns only once they are gone, and the example passes without waiting. This is also what a caller ofcloseshould get,Logtail::Loggercalls it fromat_exit.🤖 Generated with Claude Code