88
99
1010ALLOWED_METHODS = {'post' }
11- TIMEOUT = 600 # 10 minutes
11+ DEFAULT_TIMEOUT = 600 # 10 minutes
1212
1313
14- def _requests_http_request (url , method , data ):
14+ def _requests_http_request (url , method , data , timeout = DEFAULT_TIMEOUT ):
1515 normalized_method = method .lower ()
1616 if normalized_method in ALLOWED_METHODS :
1717 return getattr (requests , normalized_method )(
@@ -20,16 +20,16 @@ def _requests_http_request(url, method, data):
2020 headers = {
2121 'User-Agent' : 'Plaid Python v{}' .format (__version__ ),
2222 },
23- timeout = TIMEOUT ,
23+ timeout = timeout ,
2424 )
2525 else :
2626 raise Exception (
2727 'Invalid request method {}' .format (method )
2828 )
2929
3030
31- def http_request (url , method = None , data = None ):
32- response = _requests_http_request (url , method , data or {})
31+ def http_request (url , method = None , data = None , timeout = DEFAULT_TIMEOUT ):
32+ response = _requests_http_request (url , method , data or {}, timeout )
3333 response_body = json .loads (response .text )
3434 if response_body .get ('error_type' ):
3535 raise PlaidError .from_response (response_body )
0 commit comments