File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
- from pandas . compat import StringIO
2
+ import time
3
3
4
+ from pandas .compat import StringIO
4
5
import pandas .compat as compat
5
6
import pandas as pd
6
7
@@ -66,6 +67,8 @@ def __init__(self,
66
67
}
67
68
self .session .headers .update (headers )
68
69
self ._base_url = "https://public.enigma.com/api"
70
+ self ._retry_count = retry_count
71
+ self ._retry_delay = pause
69
72
70
73
def read (self ):
71
74
try :
@@ -80,11 +83,21 @@ def _read(self):
80
83
return pd .read_csv (StringIO (decoded_data ))
81
84
82
85
def _get (self , url ):
83
- """HTTP GET Request"""
86
+ """HTTP GET Request with Retry Logic """
84
87
url = "{0}/{1}" .format (self ._base_url , url )
85
- response = self .session .get (url )
86
- response .raise_for_status ()
87
- return response
88
+ attempts = 0
89
+ while True :
90
+ try :
91
+ response = self .session .get (url )
92
+ response .raise_for_status ()
93
+ return response
94
+ except Exception as e :
95
+ if attempts < self ._retry_count :
96
+ attempts += 1
97
+ time .sleep (self ._retry_delay )
98
+ continue
99
+ else :
100
+ raise e
88
101
89
102
def get_current_snapshot_id (self ):
90
103
"""Get ID of the most current snapshot of a dataset"""
You can’t perform that action at this time.
0 commit comments