improve waiting times

sync2
Laurent 8 months ago
parent 760a3135ad
commit 633d50a616
  1. 12
      LeStorage/ApiCallCollection.swift

@ -226,12 +226,12 @@ actor ApiCallCollection<T: SyncedStorable>: SomeCallCollection {
/// Wait for an exponentionnaly long time depending on the number of attemps
fileprivate func _wait() async {
#if DEBUG
let seconds = self._attemptLoops
#else
let delay = pow(2, self._attemptLoops)
let seconds = NSDecimalNumber(decimal: delay).intValue
#endif
var seconds = self._attemptLoops
if self._attemptLoops > 5 {
let delay = pow(2, self._attemptLoops - 2) // starts at 16s
seconds = NSDecimalNumber(decimal: delay).intValue
}
Logger.log("\(T.resourceName()): wait for \(seconds) sec")
do {
try await Task.sleep(until: .now + .seconds(seconds))

Loading…
Cancel
Save