@@ -226,7 +226,7 @@ Start by creating a strategy skeleton:
226
226
import attr
227
227
228
228
from labgrid.step import step
229
- from labgrid.strategy import Strategy, StrategyError
229
+ from labgrid.strategy import Strategy, StrategyError, never_retry
230
230
from labgrid.factory import target_factory
231
231
232
232
class Status(enum.Enum):
@@ -239,6 +239,7 @@ Start by creating a strategy skeleton:
239
239
240
240
status = attr.ib(default=Status.unknown)
241
241
242
+ @never_retry
242
243
@step()
243
244
def transition(self, status, *, step):
244
245
if not isinstance(status, Status):
@@ -262,9 +263,21 @@ It is possible to reference drivers via their protocol, e.g.
262
263
Note that drivers which implement multiple protocols must not be referenced
263
264
multiple times via different protocols.
264
265
The ``Status `` class needs to be extended to cover the states of your strategy,
265
- then for each state an ``elif `` entry in the transition function needs to be
266
+ then for each state an ``elif `` entry in the `` transition() `` method needs to be
266
267
added.
267
268
269
+ .. note ::
270
+ Since infrastructure failures or broken strategies typically cannot recover,
271
+ it makes little sense to continue operating with such a strategy after an
272
+ error has occurred.
273
+ To clearly mark a strategy as unusable after failure (and to avoid cascading
274
+ errors in subsequent calls) the strategy's ``transition() `` method (and
275
+ optionally its ``force() `` method) can be decorated with the
276
+ ``@never_retry `` decorator.
277
+ This decorator causes the strategy to store the encountered exception in its
278
+ ``broken `` attribute and raise a ``StrategyError `` for the original and all
279
+ subsequent calls to the decorated methods.
280
+
268
281
Lets take a look at the builtin `BareboxStrategy `.
269
282
The Status enum for the BareboxStrategy:
270
283
0 commit comments