Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't block on tail.Lines on shutdown #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lmars
Copy link

@lmars lmars commented Oct 24, 2017

It is quite typical to do something like the following to cancel tailing a file:

go func() {
	defer t.Stop()
	for {
		select {
		case line, ok := t.Lines:
			// ...
		case <-ctx.Done():
			return
	}
}

but then this means after the context is cancelled, there is no reader of the Tail.Lines channel and the library will block.

This change modifies the library to always select on Tail.Dying() when sending to Tail.Lines in case the user has stopped receiving and stopped the tailing.

Signed-off-by: Lewis Marshall <lewis@lmars.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant