What is the correct approach when writing cellular works that communicate with the service, which has range limits and sometimes, Never missing (not responding) for a long period of time?
Do I have to use retraining work? What if the service is missing too much time? Is there a way to store this work for a long time after execution?
What if this is a substrask in a long task?
First of all, I recommend setting socket timeouts to avoid long wait times of feedback . You can catch the socket timeout apnea and in the case of these particles, with a large amount of time to try again for 15 minutes. Even then, generally I use an incremental reuse with the percentage of increment, it increases the time in every effort to retry the task, it is useful when you write a dependent job on external service which is long May be available till time. You can set the time when you try the standard retry using a high number of retries as well as var on the task
# 20 seconds self.default_retry_delay = 20 You can apply a method like this for your work
def incrementalRetry (self, exc, perc = 20, args = none): " "By default, delay increases by 20 percent" "Arguments: auto .request.args = args delay = self.default_retry_delay if self.request.kwargs.has_key ('retry_deleay'): Delay = self. Request.kwargs ['retry_deleay'] retry_delay = Delay + Round (Delay * perc) / 100,2) # Print "Delay" + str (retry_delay) Self. Reti (auto. Request), self request. Kwargs.update ({'retry_deleay': retry_delay}), exc What if this is a subtask in a long task?
If you do not need this, you can launch it in Async mode using task.delay (args = []). Allows you to launch different functions and after all the finish you can do something else to work in the flow.
Comments
Post a Comment