diff --git a/supabase_functions/_async/functions_client.py b/supabase_functions/_async/functions_client.py index 8e84acd..0e24bca 100644 --- a/supabase_functions/_async/functions_client.py +++ b/supabase_functions/_async/functions_client.py @@ -7,7 +7,7 @@ class AsyncFunctionsClient: - def __init__(self, url: str, headers: Dict, verify: bool = True): + def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True): self.url = url self.headers = { "User-Agent": f"supabase-py/functions-py v{__version__}", @@ -17,6 +17,7 @@ def __init__(self, url: str, headers: Dict, verify: bool = True): base_url=self.url, headers=self.headers, verify=bool(verify), + timeout=timeout, follow_redirects=True, http2=True, ) diff --git a/supabase_functions/_sync/functions_client.py b/supabase_functions/_sync/functions_client.py index d09d66c..c125ea5 100644 --- a/supabase_functions/_sync/functions_client.py +++ b/supabase_functions/_sync/functions_client.py @@ -7,7 +7,7 @@ class SyncFunctionsClient: - def __init__(self, url: str, headers: Dict, verify: bool = True): + def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True): self.url = url self.headers = { "User-Agent": f"supabase-py/functions-py v{__version__}", @@ -17,6 +17,7 @@ def __init__(self, url: str, headers: Dict, verify: bool = True): base_url=self.url, headers=self.headers, verify=bool(verify), + timeout=timeout, follow_redirects=True, http2=True, ) diff --git a/supabase_functions/utils.py b/supabase_functions/utils.py index fbdd194..15af53d 100644 --- a/supabase_functions/utils.py +++ b/supabase_functions/utils.py @@ -3,6 +3,8 @@ __version__ = "0.4.6" +DEFAULT_FUNCTION_CLIENT_TIMEOUT = 5 + class SyncClient(BaseClient): def aclose(self) -> None: diff --git a/tests/_async/clients.py b/tests/_async/clients.py index 23a7d9f..38526a6 100644 --- a/tests/_async/clients.py +++ b/tests/_async/clients.py @@ -23,4 +23,5 @@ def function_client(): "apiKey": mock_access_token(), "Authorization": f"Bearer {mock_access_token()}", }, + timeout=10, ) diff --git a/tests/_sync/clients.py b/tests/_sync/clients.py index 8b4b3f8..14da8b5 100644 --- a/tests/_sync/clients.py +++ b/tests/_sync/clients.py @@ -23,4 +23,5 @@ def function_client(): "apiKey": mock_access_token(), "Authorization": f"Bearer {mock_access_token()}", }, + timeout=10, )