示例#1
0
    def get_credentials(self):
        future = Future()

        def _on_complete(error_code, access_key_id, secret_access_key,
                         session_token):
            try:
                if error_code:
                    future.set_exception(
                        awscrt.exceptions.from_code(error_code))
                else:
                    credentials = AwsCredentials(access_key_id,
                                                 secret_access_key,
                                                 session_token)
                    future.set_result(credentials)

            except Exception as e:
                future.set_exception(e)

        try:
            _awscrt.credentials_provider_get_credentials(
                self._binding, _on_complete)
        except Exception as e:
            future.set_result(e)

        return future
示例#2
0
    def get_credentials(self):
        """
        Asynchronously fetch AwsCredentials.

        Returns:
            concurrent.futures.Future: A Future which will contain
            :class:`AwsCredentials` (or an exception) when the operation completes.
            The operation may complete on a different thread.
        """
        future = Future()

        def _on_complete(error_code, binding):
            try:
                if error_code:
                    future.set_exception(
                        awscrt.exceptions.from_code(error_code))
                else:
                    credentials = AwsCredentials._from_binding(binding)
                    future.set_result(credentials)

            except Exception as e:
                future.set_exception(e)

        try:
            _awscrt.credentials_provider_get_credentials(
                self._binding, _on_complete)
        except Exception as e:
            future.set_exception(e)

        return future
示例#3
0
    def get_credentials(self):
        future = Future()

        def _on_complete(error_code, binding):
            try:
                if error_code:
                    future.set_exception(
                        awscrt.exceptions.from_code(error_code))
                else:
                    credentials = AwsCredentials._from_binding(binding)
                    future.set_result(credentials)

            except Exception as e:
                future.set_exception(e)

        try:
            _awscrt.credentials_provider_get_credentials(
                self._binding, _on_complete)
        except Exception as e:
            future.set_result(e)

        return future