machinery icon indicating copy to clipboard operation
machinery copied to clipboard

Retry

Open eshine996 opened this issue 3 years ago • 2 comments

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.

eshine996 avatar Mar 12 '21 11:03 eshine996

// 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--

eshine996 avatar Mar 12 '21 12:03 eshine996

I will link the same opened issue. https://github.com/RichardKnop/machinery/issues/640

vrazdalovschi avatar Apr 07 '21 18:04 vrazdalovschi