1
1
from dataclasses import dataclass , field
2
- from typing import Any , Callable , Dict , Optional
2
+ from typing import Any , Callable , Dict , Optional , Union
3
3
4
4
from gotrue import SyncMemoryStorage , SyncSupportedStorage
5
+ from httpx import Timeout
6
+ from postgrest .constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT
5
7
6
8
from supabase import __version__
7
9
@@ -34,6 +36,9 @@ class ClientOptions:
34
36
fetch : Optional [Callable ] = None
35
37
"""A custom `fetch` implementation."""
36
38
39
+ timeout : Union [int , float , Timeout ] = DEFAULT_POSTGREST_CLIENT_TIMEOUT
40
+ """Timeout passed to the SyncPostgrestClient instance."""
41
+
37
42
def replace (
38
43
self ,
39
44
schema : Optional [str ] = None ,
@@ -43,6 +48,7 @@ def replace(
43
48
local_storage : Optional [SyncSupportedStorage ] = None ,
44
49
realtime : Optional [Dict [str , Any ]] = None ,
45
50
fetch : Optional [Callable ] = None ,
51
+ timeout : Union [int , float , Timeout ] = DEFAULT_POSTGREST_CLIENT_TIMEOUT ,
46
52
) -> "ClientOptions" :
47
53
"""Create a new SupabaseClientOptions with changes"""
48
54
client_options = ClientOptions ()
@@ -55,4 +61,5 @@ def replace(
55
61
client_options .local_storage = local_storage or self .local_storage
56
62
client_options .realtime = realtime or self .realtime
57
63
client_options .fetch = fetch or self .fetch
64
+ client_options .timeout = timeout or self .timeout
58
65
return client_options
0 commit comments