66from multiprocessing import Pool
77from typing import List , Union
88
9- from dynamodb_timeseries import exceptions , DEFAULT_REGIONS
10- from dynamodb_timeseries .dynamodb import create_table , list_tables , put , put_batch , query
9+ from dynamodb_timeseries import exceptions
10+ from dynamodb_timeseries .dynamodb import CLIENT , create_table , list_tables , put , put_batch , query
1111from dynamodb_timeseries .tableresolver import MONTHLY , TableResolver
1212
1313logger = logging .getLogger (__name__ )
@@ -30,13 +30,13 @@ def __get_regions():
3030 regions = os .getenv ('DYNAMODB_TIMESERIES_REGIONS' )
3131 if regions :
3232 return [r for r in regions .split (',' )]
33- return DEFAULT_REGIONS
33+ return [ CLIENT . meta . region_name ]
3434
35- def __init__ (self , table_name_prefix : str , interval : int = MONTHLY , regions : List [str ] = None ):
35+ def __init__ (self , table_name_prefix : str , interval : int = MONTHLY , regions : List [str ] = [] ):
3636 self .table_name_prefix = table_name_prefix
3737 self .__tables = list_tables (table_name_prefix )
3838 self .tr = TableResolver (table_name_prefix , interval = interval )
39- if regions is None :
39+ if not regions :
4040 regions = self .__get_regions ()
4141 self .regions = regions
4242
@@ -106,8 +106,6 @@ def put_batch(self, records):
106106 tables [table_name ] = []
107107 tables [table_name ].append (r )
108108 for table_name , records in tables .items ():
109- try :
110- put_batch (table_name , records )
111- except exceptions .TableDoesNotExistException :
109+ if table_name not in self .__tables :
112110 self .__create_table (table_name )
113- put_batch (table_name , records )
111+ put_batch (table_name , records )
0 commit comments