Skip to content

Commit

Permalink
Return region (self) also in the case of wait_vanish
Browse files Browse the repository at this point in the history
The behavior of wait_vanish was inconsistent with all other region
methods which return either a match (a subregion with extra match
data) or themselves if no matching is done, all to allow a chain
of calls with incrementally smaller region scopes.

The same old behavior is also too complex in the sense that it
would either return a boolean if it succeeds or raise an error
thus signalling success in two separate ways. The function should
instead eitehr throw an error to signal failure or ignore errors
altogether and return a boolean status instead. Let's choose the
first which is more consistent with other methods again.
  • Loading branch information
pevogam committed Jan 25, 2023
1 parent 775350f commit 66b318f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions guibot/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,15 @@ def wait_vanish(self, target, timeout=30):
:param target: target to look for
:type target: str or :py:class:`target.Target`
:param int timeout: timeout before giving up
:returns: whether the target disappeared from the region
:rtype: bool
:returns: self
:rtype: :py:class:`Region`
:raises: :py:class:`errors.NotFindError` if match is still found
"""
log.info("Waiting for %s to vanish", target)
expires = time.time() + timeout
while time.time() < expires:
if self.exists(target, 0) is None:
return True
return self

# don't hog the CPU (as rescan within find will check the inverse)
time.sleep(GlobalConfig.rescan_speed_on_find)
Expand Down

0 comments on commit 66b318f

Please sign in to comment.