Skip to content

Commit

Permalink
feat: setting timeout for postgrest-py client (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth gabriel committed Jul 15, 2022
1 parent 3171a02 commit de5aba3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions supabase/client.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit de5aba3

Please sign in to comment.