#NEWLINE# def _update_session_token_cb( self , creds , provider = 'aws' , callback = None , error = None , attempts = 0 ) : #NEWLINE# #INDENT# "Callback to use with `async_aws_sts`. The 'provider' arg is a\n    bit misleading, it is a relic from boto and should probably be\n    left to its default. This will take the new Credentials obj from\n    `async_aws_sts.get_session_token()` and use it to update\n    self.provider, and then will clear the deque of pending requests.\n\n    A callback is optional. If provided, it must be callable without\n    any arguments.\n    " #NEWLINE# def raise_error( ) : #NEWLINE# #INDENT# self . provider . security_token = None #NEWLINE# if callable ( callback ) : #NEWLINE# #INDENT# return callback ( error = error ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . error ( error ) #NEWLINE# raise error #NEWLINE# #UNINDENT# #UNINDENT# if error : #NEWLINE# #INDENT# if isinstance ( error , InvalidClientTokenIdError ) : #NEWLINE# #INDENT# raise_error ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( attempts > self . max_sts_attempts ) : #NEWLINE# #INDENT# raise_error ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# seconds_to_wait = ( 0.1 * ( 2 ** attempts ) ) #NEWLINE# logging . warning ( ( 'Got error[ %s ] getting session token, retrying in %.02f seconds' % ( error , seconds_to_wait ) ) ) #NEWLINE# ioloop . IOLoop . current ( ) . add_timeout ( ( time . time ( ) + seconds_to_wait ) , functools . partial ( self . _update_session_token , attempts = ( attempts + 1 ) , callback = callback , bypass_lock = True ) ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . provider = Provider ( provider , creds . access_key , creds . secret_key , creds . session_token ) #NEWLINE# self . _auth_handler = HmacAuthV3HTTPHandler ( self . host , None , self . provider ) #NEWLINE# while attempts . pending_requests : #NEWLINE# #INDENT# request = self . pending_requests . pop ( ) #NEWLINE# request ( ) #NEWLINE# #UNINDENT# if callable ( callback ) : #NEWLINE# #INDENT# return callback ( )