4
4
import boto3
5
5
from botocore .exceptions import ClientError
6
6
from typing import Optional
7
+ from threading import Lock
7
8
8
9
from dbt .adapters .base import available
9
10
from dbt .adapters .sql import SQLAdapter
12
13
from dbt .events import AdapterLogger
13
14
logger = AdapterLogger ("Athena" )
14
15
16
+ boto3_client_lock = Lock ()
17
+
15
18
class AthenaAdapter (SQLAdapter ):
16
19
ConnectionManager = AthenaConnectionManager
17
20
Relation = AthenaRelation
@@ -52,7 +55,8 @@ def clean_up_partitions(
52
55
conn = self .connections .get_thread_connection ()
53
56
client = conn .handle
54
57
55
- glue_client = boto3 .client ('glue' , region_name = client .region_name )
58
+ with boto3_client_lock :
59
+ glue_client = boto3 .client ('glue' , region_name = client .region_name )
56
60
s3_resource = boto3 .resource ('s3' , region_name = client .region_name )
57
61
partitions = glue_client .get_partitions (
58
62
# CatalogId='123456789012', # Need to make this configurable if it is different from default AWS Account ID
@@ -77,7 +81,8 @@ def clean_up_table(
77
81
# Look up Glue partitions & clean up
78
82
conn = self .connections .get_thread_connection ()
79
83
client = conn .handle
80
- glue_client = boto3 .client ('glue' , region_name = client .region_name )
84
+ with boto3_client_lock :
85
+ glue_client = boto3 .client ('glue' , region_name = client .region_name )
81
86
try :
82
87
table = glue_client .get_table (
83
88
DatabaseName = database_name ,
0 commit comments