#NEWLINE# def _request( self , url , params , method = 'GET' ) : #NEWLINE# #INDENT# 'Send a request.\n\n        Honor rate limits and record some timings for stats.\n\n        :param url: url string\n        :param params: dict of call parameters\n        :param method: request method\n        ' #NEWLINE# self . _wait_rate_limit ( ) #NEWLINE# time_ = time . time ( ) #NEWLINE# try : #NEWLINE# #INDENT# if ( method == 'POST' ) : #NEWLINE# #INDENT# res = self . session . post ( url , data = params ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# res = self . session . get ( url , params = params ) #NEWLINE# #UNINDENT# #UNINDENT# except requests . exceptions . TooManyRedirects as err : #NEWLINE# #INDENT# raise err #NEWLINE# #UNINDENT# except requests . exceptions . RequestException as err : #NEWLINE# #INDENT# self . log . debug ( err ) #NEWLINE# raise DataProviderError ( ( 'request: %s' % err . message ) ) #NEWLINE# #UNINDENT# if ( not getattr ( time_ , 'from_cache' , False ) ) : #NEWLINE# #INDENT# self . stats [ 'reqs_web' ] += 1 #NEWLINE# self . stats [ 'time_resp' ] += ( time . time ( ) - time_ ) #NEWLINE# self . last_request = time_ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . stats [ 'reqs_lowcache' ] += 1 #NEWLINE# #UNINDENT# if ( res . status_code not in [ 200 , 404 ] ) : #NEWLINE# #INDENT# raise DataProviderError ( ( 'status code %d: %s' % ( res . status_code , res . reason ) ) ) #NEWLINE# #UNINDENT# return res