Синхронизировать Полли с тайм-аутом ⇐ C#
Синхронизировать Полли с тайм-аутом
This code runs to the end, no TimeoutRejectedException. If I change the strategy to TimeoutStrategy.Pessimistic, it will enter the executed logic twice, before throwing the TimeoutRejectedException.
What should I do, if I want to retry after a timeout with the retry policy? (if it does a timeout, I want to try again after a pause until I hit MaxRetries)?
Is the only solution to make my executing logic itself throw the timeout? (The code is .net framework 4.8 and it made to run in LinqPad 5 and Polly v 8.3.1).
The Optimistic strategy does not seem to actually do anything in this setup, does it?
var retry = Policy .Handle() .Retry(1); var timeout = Policy .Timeout(1, Polly.Timeout.TimeoutStrategy.Optimistic); var wrap = Policy.Wrap(retry, timeout); try { wrap .Execute(() => { "Enter executed logic".Dump(); Thread.Sleep(5000); "Exit executed logic".Dump(); }); } catch(TimeoutRejectedException ex) { ex.Message.Dump(); }
Источник: https://stackoverflow.com/questions/781 ... th-timeout
This code runs to the end, no TimeoutRejectedException. If I change the strategy to TimeoutStrategy.Pessimistic, it will enter the executed logic twice, before throwing the TimeoutRejectedException.
What should I do, if I want to retry after a timeout with the retry policy? (if it does a timeout, I want to try again after a pause until I hit MaxRetries)?
Is the only solution to make my executing logic itself throw the timeout? (The code is .net framework 4.8 and it made to run in LinqPad 5 and Polly v 8.3.1).
The Optimistic strategy does not seem to actually do anything in this setup, does it?
var retry = Policy .Handle() .Retry(1); var timeout = Policy .Timeout(1, Polly.Timeout.TimeoutStrategy.Optimistic); var wrap = Policy.Wrap(retry, timeout); try { wrap .Execute(() => { "Enter executed logic".Dump(); Thread.Sleep(5000); "Exit executed logic".Dump(); }); } catch(TimeoutRejectedException ex) { ex.Message.Dump(); }
Источник: https://stackoverflow.com/questions/781 ... th-timeout
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Selenium WebDriver: проблема с тайм-аутом щелчка по элементам и раскрывающимся спискам
Anonymous » » в форуме Python - 0 Ответы
- 52 Просмотры
-
Последнее сообщение Anonymous
-