Skip to content

Commit 0ca8835

Browse files
committed
add timeout argument for the async client
1 parent 13a44a8 commit 0ca8835

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

metabase_api/_rest_methods_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async def get(self, endpoint, *args, **kwargs):
55
await self.validate_session_async()
66
auth = (self.email, self.password) if self.auth else None
77

8-
async with httpx.AsyncClient() as client:
8+
async with httpx.AsyncClient(timeout=self.timeout) as client:
99
res = await client.get(
1010
self.domain + endpoint,
1111
headers=self.header,
@@ -22,7 +22,7 @@ async def post(self, endpoint, *args, **kwargs):
2222
await self.validate_session_async()
2323
auth = (self.email, self.password) if self.auth else None
2424

25-
async with httpx.AsyncClient() as client:
25+
async with httpx.AsyncClient(timeout=self.timeout) as client:
2626
res = await client.post(
2727
self.domain + endpoint,
2828
headers=self.header,
@@ -39,7 +39,7 @@ async def put(self, endpoint, *args, **kwargs):
3939
await self.validate_session_async()
4040
auth = (self.email, self.password) if self.auth else None
4141

42-
async with httpx.AsyncClient() as client:
42+
async with httpx.AsyncClient(timeout=self.timeout) as client:
4343
res = await client.put(
4444
self.domain + endpoint,
4545
headers=self.header,
@@ -56,7 +56,7 @@ async def delete(self, endpoint, *args, **kwargs):
5656
await self.validate_session_async()
5757
auth = (self.email, self.password) if self.auth else None
5858

59-
async with httpx.AsyncClient() as client:
59+
async with httpx.AsyncClient(timeout=self.timeout) as client:
6060
res = await client.delete(
6161
self.domain + endpoint,
6262
headers=self.header,

metabase_api/metabase_api_async.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Metabase_API_Async:
77
Provides asynchronous methods to interact with the Metabase API.
88
"""
99

10-
def __init__(self, domain, email=None, password=None, api_key=None, basic_auth=False, is_admin=True):
10+
def __init__(self, domain, email=None, password=None, api_key=None, basic_auth=False, is_admin=True, timeout=None):
1111
assert email is not None or api_key is not None
1212
self.domain = domain.rstrip('/')
1313
self.email = email
@@ -16,6 +16,7 @@ def __init__(self, domain, email=None, password=None, api_key=None, basic_auth=F
1616
self.session_id = None
1717
self.header = None
1818
self.is_admin = is_admin
19+
self.timeout = timeout
1920

2021
if email:
2122
self.password = getpass.getpass(prompt='Please enter your password: ') if password is None else password

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="metabase-api",
8-
version="3.5",
8+
version="3.5.1",
99
author="Vahid Vaezian",
1010
author_email="vahid.vaezian@gmail.com",
1111
description="A Python Wrapper for Metabase API",

0 commit comments

Comments
 (0)