| 1643 | |
| 1644 | @ct.extension(name="fail-rate", data=FailRateData) |
| 1645 | class FailRate(ct.ExtensibleRate): |
| 1646 | def __init__(self, *args, recoverable, **kwargs): |
| 1647 | super().__init__(*args, **kwargs) |
| 1648 | self.recoverable = recoverable |
| 1649 | self.count = 0 |
| 1650 | |
| 1651 | def eval(self, data): |
| 1652 | if data.fail: |
| 1653 | self.count += 1 |
| 1654 | if self.count < 3 or not self.recoverable: |
| 1655 | raise ValueError("spam") |
| 1656 | return 0.0 |
| 1657 | |
| 1658 | |
| 1659 | class TestFlowReactor: |
no outgoing calls