Method: ActiveModel::Datastore::ClassMethods#retry_on_exception?
- Defined in:
- lib/active_model/datastore.rb
#retry_on_exception?(max_retry_count = 5) ⇒ Boolean
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/active_model/datastore.rb', line 403 def retry_on_exception?(max_retry_count = 5) retries = 0 sleep_time = 0.25 begin yield rescue Google::Cloud::Error => e return false if retries >= max_retry_count puts "\e[33mRescued exception #{e..inspect}, retrying in #{sleep_time}\e[0m" # 0.25, 0.5, 1, 2, and 4 second between retries. sleep sleep_time retries += 1 sleep_time *= 2 retry end end |