diff --git a/.gitignore b/.gitignore index b8d17e8..8044423 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ wheels/ .installed.cfg *.egg .vscode/ +.DS_Store # PyInstaller # Usually these files are written by a python script from a template diff --git a/pinotdb/db.py b/pinotdb/db.py index 4580895..e3d73b7 100644 --- a/pinotdb/db.py +++ b/pinotdb/db.py @@ -286,6 +286,7 @@ def __init__( # TODO: Remove this unused parameter when we can afford to break the # interface (e.g. new minor version). verify_ssl=True, + timeout=10, extra_request_headers="", debug=False, preserve_types=False, diff --git a/pinotdb/sqlalchemy.py b/pinotdb/sqlalchemy.py index b5486c1..0487beb 100644 --- a/pinotdb/sqlalchemy.py +++ b/pinotdb/sqlalchemy.py @@ -163,6 +163,7 @@ def __init__(self, *args, **kwargs): self._password = None self._debug = False self._verify_ssl = True + self._timeout = 10.0 self._database = None self.update_from_kwargs(kwargs) @@ -181,6 +182,7 @@ def update_from_kwargs(self, givenkw): kwargs["database"] = self._database = kwargs.pop("database") kwargs["debug"] = self._debug = bool(kwargs.get("debug", False)) kwargs["verify_ssl"] = self._verify_ssl = (str(kwargs.get("verify_ssl", "true")).lower() in ['true']) + kwargs["timeout"] = self._timeout = kwargs.get("timeout", None) logger.info( "Updated pinot dialect args from %s: %s and %s", dict(map(lambda kv: (kv[0], mask_value(kv[0], kv[1], ['password'])), kwargs.items())), @@ -207,6 +209,7 @@ def create_connect_args(self, url): "username": url.username, "password": url.password, "verify_ssl": self._verify_ssl or True, + "timeout": self._timeout or 10.0, } if self.engine_type == "multi_stage": kwargs.update({"use_multistage_engine": True}) diff --git a/poetry.lock b/poetry.lock index eec7a74..d8deebe 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. [[package]] name = "anyio" @@ -46,13 +46,13 @@ files = [ [[package]] name = "certifi" -version = "2024.6.2" +version = "2024.7.4" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ - {file = "certifi-2024.6.2-py3-none-any.whl", hash = "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56"}, - {file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"}, + {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, + {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, ] [[package]] @@ -317,13 +317,13 @@ files = [ [[package]] name = "exceptiongroup" -version = "1.2.1" +version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ - {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, - {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, + {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, + {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, ] [package.extras] diff --git a/tests/unit/test_sqlalchemy.py b/tests/unit/test_sqlalchemy.py index 1393e7e..1809393 100644 --- a/tests/unit/test_sqlalchemy.py +++ b/tests/unit/test_sqlalchemy.py @@ -56,6 +56,7 @@ def test_creates_connection_args(self): 'username': None, 'password': None, 'verify_ssl': True, + 'timeout': 10.0, }) def test_creates_connection_args_without_query(self): @@ -73,6 +74,7 @@ def test_creates_connection_args_without_query(self): 'username': None, 'password': None, 'verify_ssl': True, + 'timeout': 10.0, }) def test_can_instantiate_with_server(self): @@ -282,6 +284,7 @@ def test_creates_connection_args(self): 'username': None, 'password': None, 'verify_ssl': True, + 'timeout': 10.0, 'use_multistage_engine': True, })