Skip to content

Commit

Permalink
feat: added timeout to options
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth gabriel committed Jul 15, 2022
1 parent de5aba3 commit 069ada2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions supabase/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(
auth_url=self.auth_url,
supabase_key=self.supabase_key,
client_options=options,

)
# TODO(fedden): Bring up to parity with JS client.
# self.realtime: SupabaseRealtimeClient = self._init_realtime_client(
Expand All @@ -60,6 +61,7 @@ def __init__(
supabase_key=self.supabase_key,
headers=options.headers,
schema=options.schema,
timeout=options.timeout
)

def storage(self) -> SupabaseStorageClient:
Expand Down
9 changes: 8 additions & 1 deletion supabase/lib/client_options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, Optional
from typing import Any, Callable, Dict, Optional, Union

from gotrue import SyncMemoryStorage, SyncSupportedStorage
from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
from httpx import Timeout

from supabase import __version__

Expand Down Expand Up @@ -34,6 +36,9 @@ class ClientOptions:
fetch: Optional[Callable] = None
"""A custom `fetch` implementation."""

timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT
"""Timeout passed to the SyncPostgrestClient instance."""

def replace(
self,
schema: Optional[str] = None,
Expand All @@ -43,6 +48,7 @@ def replace(
local_storage: Optional[SyncSupportedStorage] = None,
realtime: Optional[Dict[str, Any]] = None,
fetch: Optional[Callable] = None,
timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT
) -> "ClientOptions":
"""Create a new SupabaseClientOptions with changes"""
client_options = ClientOptions()
Expand All @@ -55,4 +61,5 @@ def replace(
client_options.local_storage = local_storage or self.local_storage
client_options.realtime = realtime or self.realtime
client_options.fetch = fetch or self.fetch
client_options.timeout = timeout or self.timeout
return client_options

0 comments on commit 069ada2

Please sign in to comment.