diff --git a/supabase/client.py b/supabase/client.py index 007b6d1e..336f0be9 100644 --- a/supabase/client.py +++ b/supabase/client.py @@ -1,11 +1,12 @@ -from typing import Any, Dict +from typing import Any, Dict, Union from postgrest import SyncFilterRequestBuilder, SyncPostgrestClient, SyncRequestBuilder +from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT from .lib.auth_client import SupabaseAuthClient from .lib.client_options import ClientOptions from .lib.storage_client import SupabaseStorageClient - +from httpx import Timeout class Client: """Supabase client class.""" @@ -152,10 +153,14 @@ def _init_supabase_auth_client( @staticmethod def _init_postgrest_client( - rest_url: str, supabase_key: str, headers: Dict[str, str], schema: str + rest_url: str, + supabase_key: str, + headers: Dict[str, str], + schema: str, + timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT ) -> SyncPostgrestClient: """Private helper for creating an instance of the Postgrest client.""" - client = SyncPostgrestClient(rest_url, headers=headers, schema=schema) + client = SyncPostgrestClient(rest_url, headers=headers, schema=schema, timeout=timeout) client.auth(token=supabase_key) return client