def execute(self): """ Execute all of the saved commands and return results. """ try: for key, value in self._watched_keys.items(): if self.mock_redis.redis.get(key) != value: raise WatchError("Watched variable changed.") return [command() for command in self.commands] finally: self._reset()
async def execute(self): """ Execute all of the saved commands and return results. """ try: for key, value in self._watched_keys.items(): if self.mock_redis.redis.get(self.mock_redis._encode(key)) != value: raise WatchError("Watched variable changed.") results = [] for command in self.commands: results.append(await command()) return results finally: self._reset()