Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multi-thread issues by removing global boto3 session #45

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions dbt/adapters/athena/session.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
from typing import Optional

import boto3.session
from dbt.contracts.connection import Connection

__BOTO3_SESSION__: Optional[boto3.session.Session] = None


def get_boto3_session(connection: Connection = None) -> boto3.session.Session:
def init_session():
global __BOTO3_SESSION__
__BOTO3_SESSION__ = boto3.session.Session(
region_name=connection.credentials.region_name,
profile_name=connection.credentials.aws_profile_name,
)

if not __BOTO3_SESSION__:
if connection is None:
raise RuntimeError(
"A Connection object needs to be passed to initialize the boto3 session for the first time"
)
init_session()
if connection is None:
raise RuntimeError("A Connection object needs to be passed to initialize the boto3 session")

return __BOTO3_SESSION__
return boto3.session.Session(
region_name=connection.credentials.region_name,
profile_name=connection.credentials.aws_profile_name,
)