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

retry when no found file #13

Closed
wants to merge 1 commit into from
Closed

Conversation

yqylovy
Copy link

@yqylovy yqylovy commented Jun 17, 2016

when process is executing the TryLock() and another process Unlock(),the process will return a no such file or directory error, which is ignorable.So I change it to just try again.

@nightlyone
Copy link
Owner

First of all: Thanks a lot for your contribution!

Now that I thought a few days about it it, I came to the conclusion that the retry is better handled outside in the caller of this package.

The TryLock is intended to be called in a loop until it succeeds. How many times you want to retry that loop until you give up and how long to wait between these tries should be up to the caller of this package.

See https://github.com/Jimdo/periodicnoise/blob/master/cmd/pn/core.go#L40 and https://github.com/Jimdo/periodicnoise/blob/master/cmd/pn/core.go#L67-L80 for such a loop.

So it is an orthogonal problem and there are packages for this already. See https://godoc.org/github.com/juju/retry or the results of this search https://godoc.org/?q=retry and this search for the waiting part https://godoc.org/?q=backoff to find a fitting solution.

But many thanks for telling me about this interesting race condition that I wasn't aware of! I will make this case easier to handle in a different change using a custom error suggesting a retry.

I will mention you and would like your feedback there.

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.

2 participants