Retriable only trying for 20 times even though my tries is 360. Not sure why that's happpening.
sandipsubedi opened this issue ยท 3 comments
sandipsubedi commented
I want to retry my logic for 1 hour if something is not true. So I added tries as 360
and base_interval
: as 10. But for some reason, it always exists out in 20 times. Following is my code and log:
Code
count = 0
# 1 hour : 10 second interval x 360 tries = 3600 seconds
Retriable.retriable(on: [MyModule::MyClass::CustomError, Net::OpenTimeout],
tries: 360, base_interval: 10) do
count += 1
print "count: #{count} \n"
raise MyModule::MyClass::CustomError if @food != "tacos"
end
Log:
[5] pry(main)> work.run
count: 1
count: 2
count: 3
count: 4
count: 5
count: 6
count: 7
count: 8
count: 9
count: 10
count: 11
count: 12
count: 13
count: 14
count: 15
count: 16
count: 17
count: 18
count: 19
count: 20
MyModule::MyClass::CustomError: MyModule::MyClass::CustomError
Am I missing anything? Any idea on how I can accomplish this?
scalp42 commented
Have a look at the options: there's a max_elapsed_time
se to 15 mins. I could be wrong ๐
sandipsubedi commented
Have a look at the options: there's a
max_elapsed_time
se to 15 mins. I could be wrong ๐
Ooops.. I need to read documentation better. That's the reason. It's working fine now after I set max_elapsed_time to 3600.
. Thank you so much for your replying.
scalp42 commented
Happens to the best of us.
You're very much welcome @sandipsubedi, I was just passing by ๐