machinery
machinery copied to clipboard
Retry
When tasks need to retry the configuration in the signature RetryCount/RetryTimeout, task thrown in panic may try again in accordance with the relevant rules, but use "return tasks. NewErrRetryTaskLater (" 2 ", 4 * time. The Second)" into an infinite loop.I think you should pass the task structure into the task, just like Python's celery.
// Call the task
results, err := task.Call()
if err != nil {
//All retry mechanisms are based on the RetryCount
if signature.RetryCount < 0 {
return worker.taskFailed(signature, err)
}
// If a tasks.ErrRetryTaskLater was returned from the task,
// retry the task after specified duration
retriableErr, ok := interface{}(err).(tasks.ErrRetryTaskLater)
if ok {
return worker.retryTaskIn(signature, retriableErr.RetryIn())
}
return worker.taskRetry(signature)
//return worker.taskFailed(signature, err)
}
return worker.taskSucceeded(signature, results)
} 在func retryTaskIn 中加入 signature.RetryCount--
I will link the same opened issue. https://github.com/RichardKnop/machinery/issues/640