mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
executeUnsafe to loop
This commit is contained in:
parent
90c3cd1b23
commit
4003fdbcd1
@ -13,6 +13,8 @@
|
||||
|
||||
### 0.10.1
|
||||
|
||||
* Change algorithm of `executeUnsafe`: now it use loop instead of recursive calling
|
||||
|
||||
## 0.9.0
|
||||
|
||||
* Old extension `OkHttpClient.Builder#useWith` now deprecated and must be replaced by the same in
|
||||
|
@ -173,14 +173,17 @@ suspend fun <T: Any> RequestsExecutor.executeUnsafe(
|
||||
retries: Int = 0,
|
||||
retriesDelay: Long = 1000L
|
||||
): T? {
|
||||
return try {
|
||||
execute(request)
|
||||
var leftRetries = retries
|
||||
while(true) {
|
||||
try {
|
||||
return execute(request)
|
||||
} catch (e: RequestException) {
|
||||
if (retries > 0) {
|
||||
if (leftRetries > 0) {
|
||||
leftRetries--
|
||||
delay(retriesDelay)
|
||||
executeUnsafe(request, retries - 1, retriesDelay)
|
||||
} else {
|
||||
null
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user