Validate the network resource with exponential backoff

def validate_resource(self, value):
        """Validate the network resource with exponential backoff"""

        def do_backoff(*args, **kwargs):
            """Call self._test_connection with exponential backoff, for self._max_tries attempts"""
            attempts = 0
            while True:
                try:
                    self._test_connection(*args, **kwargs)
                    break
                except ValidationError:
                    wait_secs = min(self._max_wait, 2 ** attempts)
                    attempts += 1
                    if attempts < self._max_tries:
                        time.sleep(wait_secs)
                    else:
                        raise

        do_backoff(value)