@@ -560,6 +560,17 @@ def _create_dict_ent(self, up_ticker, statement_type, tech_type, report_name, hi
560
560
dict_ent = {up_ticker : re_data }
561
561
return dict_ent
562
562
563
+ def _retry_create_dict_ent (self , up_ticker , statement_type , tech_type , report_name , hist_obj ):
564
+ i = 0
565
+ while i < 250 :
566
+ try :
567
+ out = self ._create_dict_ent (up_ticker , statement_type , tech_type , report_name , hist_obj )
568
+ return out
569
+ except :
570
+ time .sleep (random .randint (2 , 10 ))
571
+ i += 1
572
+ continue
573
+
563
574
# Private method to return the stmt_id for the reformat_process
564
575
def _get_stmt_id (self , statement_type , raw_data ):
565
576
stmt_id = ''
@@ -611,17 +622,17 @@ def get_time_code(self, time_interval):
611
622
# Public Method to get stock data
612
623
def get_stock_data (self , statement_type = 'income' , tech_type = '' , report_name = '' , hist_obj = {}):
613
624
data = {}
614
- if statement_type == 'income' and tech_type == '' and report_name == '' : # temp, so this method doesn't return nulls
625
+ if statement_type == 'income' and tech_type == '' and report_name == '' : # temp, so this method doesn't return nulls
615
626
statement_type = 'profile'
616
627
tech_type = 'assetProfile'
617
628
report_name = 'assetProfile'
618
629
if isinstance (self .ticker , str ):
619
- dict_ent = self ._create_dict_ent (self .ticker , statement_type , tech_type , report_name , hist_obj )
630
+ dict_ent = self ._retry_create_dict_ent (self .ticker , statement_type , tech_type , report_name , hist_obj )
620
631
data .update (dict_ent )
621
632
else :
622
633
if self .concurrent :
623
634
with Pool (self ._get_worker_count ()) as pool :
624
- dict_ents = pool .map (partial (self ._create_dict_ent ,
635
+ dict_ents = pool .map (partial (self ._retry_create_dict_ent ,
625
636
statement_type = statement_type ,
626
637
tech_type = tech_type ,
627
638
report_name = report_name ,
0 commit comments