Retries and begin again from the beginning :param attemps: number of maximum retries :param wait: time to wait in seconds before retry :param msg: message passed to fail if attemps value was reached
(self, attemps=5, wait=1, msg="", msgfail=_("Max retries reached"))
| 448 | raise Retry(encode(msg)) # @TODO: Remove `encode` in 0.4.10 |
| 449 | |
| 450 | def retry(self, attemps=5, wait=1, msg="", msgfail=_("Max retries reached")): |
| 451 | """ |
| 452 | Retries and begin again from the beginning |
| 453 | |
| 454 | :param attemps: number of maximum retries |
| 455 | :param wait: time to wait in seconds before retry |
| 456 | :param msg: message passed to fail if attemps value was reached |
| 457 | """ |
| 458 | frame = inspect.currentframe() |
| 459 | |
| 460 | try: |
| 461 | id = frame.f_back.f_lineno |
| 462 | finally: |
| 463 | del frame #: Delete the frame or it wont be cleaned |
| 464 | |
| 465 | if id not in self.retries: |
| 466 | self.retries[id] = 0 |
| 467 | |
| 468 | if 0 < attemps <= self.retries[id]: |
| 469 | self.fail(msgfail) |
| 470 | |
| 471 | self.retries[id] += 1 |
| 472 | |
| 473 | self.wait(wait) |
| 474 | |
| 475 | raise Retry(encode(msg)) # @TODO: Remove `encode` in 0.4.10 |
| 476 | |
| 477 | def retry_captcha(self, attemps=10, wait=1, msg="", msgfail=_("Max captcha retries reached")): |
| 478 | self.captcha.invalid(msg) |
no test coverage detected