Module: Gitlab::LoopHelpers
- Included in:
- Ci::JobArtifacts::DestroyAllExpiredService, Ci::JobArtifacts::UpdateUnknownLockedStatusService, Ci::PipelineArtifacts::DestroyAllExpiredService, Environments::AutoDeleteCronWorker, Environments::AutoRecoverService, Environments::AutoStopService, Ci::Components::InstancePath
- Defined in:
- lib/gitlab/loop_helpers.rb
Instance Method Summary collapse
-
#loop_until(timeout: nil, limit: 1_000_000) ⇒ Object
This helper method repeats the same task until it’s expired.
Instance Method Details
#loop_until(timeout: nil, limit: 1_000_000) ⇒ Object
This helper method repeats the same task until it’s expired.
Note: ExpiredLoopError does not happen until the given block finished.
Please do not use this method for heavy or asynchronous operations.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab/loop_helpers.rb', line 10 def loop_until(timeout: nil, limit: 1_000_000) raise ArgumentError unless limit start = Time.now limit.times do return true unless yield return false if timeout && (Time.now - start) > timeout end false end |