Process events until ``condition()`` returns ``True``. :param condition: Condition which determines when the wait will end. :param timeout: Timeout in seconds. If ``False``, the value of ``timeout`` used in the constructor of this object will be used. If ``None`
(
self,
condition: Callable[[], bool],
timeout: Union[None, Literal[False], float] = False,
msg: Optional[str] = None
)
| 496 | self.container.process() |
| 497 | |
| 498 | def wait( |
| 499 | self, |
| 500 | condition: Callable[[], bool], |
| 501 | timeout: Union[None, Literal[False], float] = False, |
| 502 | msg: Optional[str] = None |
| 503 | ) -> None: |
| 504 | """ |
| 505 | Process events until ``condition()`` returns ``True``. |
| 506 | |
| 507 | :param condition: Condition which determines when the wait will end. |
| 508 | :param timeout: Timeout in seconds. If ``False``, the value of ``timeout`` used in the |
| 509 | constructor of this object will be used. If ``None``, there is no timeout. Any other |
| 510 | value is treated as a timeout in seconds. |
| 511 | :param msg: Context message for :class:`proton.Timeout` exception |
| 512 | """ |
| 513 | if timeout is False: |
| 514 | timeout = self.timeout |
| 515 | if timeout is None: |
| 516 | while not condition() and not self.disconnected: |
| 517 | self.container.process() |
| 518 | else: |
| 519 | container_timeout = self.container.timeout |
| 520 | self.container.timeout = timeout |
| 521 | try: |
| 522 | deadline = time.time() + timeout |
| 523 | while not condition() and not self.disconnected: |
| 524 | self.container.process() |
| 525 | if deadline < time.time(): |
| 526 | txt = "Connection %s timed out" % self.url |
| 527 | if msg: |
| 528 | txt += ": " + msg |
| 529 | raise Timeout(txt) |
| 530 | finally: |
| 531 | self.container.timeout = container_timeout |
| 532 | if self.disconnected and not self._is_closed(): |
| 533 | raise ConnectionException( |
| 534 | "Connection %s disconnected: %s" % (self.url, self.disconnected)) |
| 535 | |
| 536 | def on_link_remote_close(self, event: 'Event') -> None: |
| 537 | """ |
no test coverage detected