gemseo.disciplines.wrappers.retry_discipline module#
The retry discipline.
- class RetryDiscipline(discipline, n_trials=5, wait_time=0.0, timeout=inf, fatal_exceptions=())[source]#
Bases:
DisciplineA discipline to be executed with retry and timeout options.
This
Disciplinewraps another discipline.It can be executed multiple times (up to a specified number of trials) if the previous attempts fail to produce any result.
A timeout in seconds can be specified to prevent executions from becoming stuck.
Users can also provide a tuple of
Exceptionthat, if one of them is raised, it does not retry the execution.Please note that the
TimeoutErrorexception is also caught if the wrapped discipline raises such an exception (i.e. aside fromRetryDisciplineitself). So it could lead to 2 surprising cases, but in fact normal cases: - aTimeoutErrorexception even though the user didn't provide any timeout value. - aTimeoutErrorraised sooner than thetimeoutvalue set by the user.Initialize self. See help(type(self)) for accurate signature.
- Parameters:
discipline (Discipline) -- The discipline to wrap in the retry loop.
n_trials (int) --
The number of trials of the discipline.
By default it is set to 5.
wait_time (float) --
The time to wait between 2 trials (in seconds).
By default it is set to 0.0.
timeout (float) --
The maximum duration, in seconds, that the discipline is allowed to run. If this time limit is exceeded, the execution is terminated. If
math.inf, the discipline is executed without timeout limit.By default it is set to inf.
fatal_exceptions (Iterable[type[Exception]]) --
The exceptions for which the code raises an exception and exit immediately without retrying a run.
By default it is set to ().
- Raises:
TimeoutError -- If the
timeoutlimit is reached.Exception -- Other exceptions if an issue is encountered during the execution of
discipline.