Questions tagged [retry-logic]

Programming techniques designed to retry operations that failed due to error codes, exceptions, or other language specific means.

377 questions
34
votes
3 answers

What is the benefit of using exponential backoff?

When the code is waiting for some condition in which delay time is not deterministic, it looks like many people choose to use exponential backoff, i.e. wait N seconds, check if the condition satisfies; if not, wait for 2N seconds, check the…
xis
  • 24,330
  • 9
  • 43
  • 59
22
votes
5 answers

Retry function in Python

Some time ago, I was in need of a retry function in R to handle slow servers response. The function would have the following behavior : (try an action (function or method), and if it fails, wait a bit and then retry)x10 I came up with the following…
François M.
  • 4,027
  • 11
  • 30
  • 81
16
votes
4 answers

Check string content of response before retrying with Polly

I'm working with a very flaky API. Sometimes I get 500 Server Error with Timeout, some other time I also get 500 Server Error because I gave it input that it can't handle SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999…
trailmax
  • 34,305
  • 22
  • 140
  • 234
16
votes
2 answers

How to retry with hystrix

I have a hystrix command that encapsulates a REST call. In case of failure(e.g. timeout), I want to make a single retry and return an appropriate error if it still fails. As I can see, Hystrix doesn't support retries. The only way to do it with…
evgeniy44
  • 2,862
  • 7
  • 28
  • 51
15
votes
2 answers

Pattern for retrying URLSession dataTask?

I'm fairly new to iOS/Swift development and I'm working on an app that makes several requests to a REST API. Here's a sample of one of those calls which retrieves "messages": func getMessages() { let endpoint = "/api/outgoingMessages" let…
bmt22033
  • 6,880
  • 14
  • 69
  • 98
13
votes
1 answer

How can I get the retry count within a delegate executed through Polly retry policy?

I'm implementing Polly to retry requests in my C# web app. My sample code is included in this post. The code works as expected but the last parameter passed to CreateFile() (currently hard-coded as 0) needs to be the value of retryAttempt. How can…
user10816949
  • 131
  • 2
  • 7
13
votes
4 answers

Retry failed sqlalchemy queries

Every time I'm restarting mysql service, my app is receiving the following error on any query: result = self._query(query) File "/usr/local/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query conn.query(q) File…
Mugen
  • 8,301
  • 10
  • 62
  • 140
13
votes
2 answers

Execute multiple policies

How to execute multiple policies (or combine them into a single one)? For example I have: var policy1 = Policy.Handle().WaitAndRetry(5)); var policy2 = Policy.Handle().RetryForever(); How to apply…
denny
  • 320
  • 3
  • 10
9
votes
2 answers

Implementing retry logic with Polly library with no exception handling repeatedly

how to implement retry logic using polly to retry executing a function forever with some delay but handle no exception. the scenario is to get status information repeatedly but there is no expected exception.
TrustyCoder
  • 4,749
  • 10
  • 66
  • 119
9
votes
1 answer

Calling execution.execute() twice in RestTemplate interceptor

I have to integrate with external service that requires access token to be sent with each requests. Access token has a short expiration time (only a few hours). I've decided to use access token in optimistic way. I'm going to call external service…
pmajcher
  • 537
  • 6
  • 14
8
votes
2 answers

Retry HTTP request (Java 11 - HttpClient)

Problem Using HttpClient from Java 11 (JDK, not Apache), how can I retry requests? Lets say I want to retry a request up to 10 times if it did not return a status code of 200 or threw an exception. Attempt Currently I am composing the returned…
Zabuzard
  • 25,064
  • 8
  • 58
  • 82
8
votes
1 answer

Polly Retry All Exceptions Except Specific Condition

Is there a way in Polly to retry all exceptions apart from those which are specified.. for example: var p = Policy .Handle(e => !(e.NativeErrorCode == 1)) .Or() .RetryAsync(); Here i have picked a…
m1nkeh
  • 1,337
  • 23
  • 45
8
votes
1 answer

Spring @Retryable for specific condition

Is it possible to retry based on certain conditions? If I annotate with Retryable, it will retry based on some Exceptions but I want to retry if that exception is caught and the corresponding conditions is…
user123475
  • 1,065
  • 4
  • 17
  • 29
7
votes
0 answers

Elasticsarch: Performing retries with a single node

I am using NEST to perform queries towards an Elasticsearch 6-cluster. The Elasticsearch cluster consists of a couple of nodes, but it's running behind a firewall/loadbalancer so from the client perspective it appears as a single node with a single…
Nitramk
  • 1,542
  • 6
  • 25
  • 42
7
votes
1 answer

C++ LibCurl retry on error

I want to retry a curl connection in my C++ program for 5 times. When it fails 5 times in a row, it should stop the execution of the program. However, it stops after the first error at this point. I am able to catch the error, however I don't know…
TVA van Hesteren
  • 1,031
  • 3
  • 20
  • 47
1
2 3
25 26