You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have 0 experience developing in go, so please be gentle if I misunderstand any of the inner workings of multi-threaded go development.
However to me, it appears that RetryNotify does not deal with operations that hang, even if a timeout is set.
doRetryNotify
Line 87 starts a for loop.
Line 88 calls the provided operation()
This is a blocking call. It waits for operation to return, and checks the return value.
Further down is a select block to wait for ctx.Done(), or the result of a timer.
But if operation() on line 88 blocks we would never get here?
I would imagine you need some code like the following inside the for loop. Again, I have 0 experience in go, this is based off what I've learned in the past 24 hours.
errCh := make(chan error)
resCh := make(chan res)
go func() {
res, err := operation()
if err != nil {
errCh <- err
return
}
resCh <- res
}()
select {
case <-ctx.Done():
return ctx.Err()
case err := <- errCh
//do the error logic here
case res := <- resCh
return res, nil
}
The text was updated successfully, but these errors were encountered:
I have 0 experience developing in go, so please be gentle if I misunderstand any of the inner workings of multi-threaded go development.
However to me, it appears that RetryNotify does not deal with operations that hang, even if a timeout is set.
RetryNotify uses RetryNotifyWithTimer uses doRetryNotify
doRetryNotify
Line 87 starts a for loop.
Line 88 calls the provided operation()
This is a blocking call. It waits for operation to return, and checks the return value.
Further down is a select block to wait for ctx.Done(), or the result of a timer.
But if operation() on line 88 blocks we would never get here?
I would imagine you need some code like the following inside the for loop. Again, I have 0 experience in go, this is based off what I've learned in the past 24 hours.
The text was updated successfully, but these errors were encountered: