Skip to content

Commit d0abc3c

Browse files
feat: add edge functions timeout (#120)
1 parent e1d064b commit d0abc3c

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

supabase_functions/_async/functions_client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class AsyncFunctionsClient:
10-
def __init__(self, url: str, headers: Dict, verify: bool = True):
10+
def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True):
1111
self.url = url
1212
self.headers = {
1313
"User-Agent": f"supabase-py/functions-py v{__version__}",
@@ -17,6 +17,7 @@ def __init__(self, url: str, headers: Dict, verify: bool = True):
1717
base_url=self.url,
1818
headers=self.headers,
1919
verify=bool(verify),
20+
timeout=timeout,
2021
follow_redirects=True,
2122
http2=True,
2223
)

supabase_functions/_sync/functions_client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class SyncFunctionsClient:
10-
def __init__(self, url: str, headers: Dict, verify: bool = True):
10+
def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True):
1111
self.url = url
1212
self.headers = {
1313
"User-Agent": f"supabase-py/functions-py v{__version__}",
@@ -17,6 +17,7 @@ def __init__(self, url: str, headers: Dict, verify: bool = True):
1717
base_url=self.url,
1818
headers=self.headers,
1919
verify=bool(verify),
20+
timeout=timeout,
2021
follow_redirects=True,
2122
http2=True,
2223
)

supabase_functions/utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
__version__ = "0.4.7"
55

6+
DEFAULT_FUNCTION_CLIENT_TIMEOUT = 5
7+
68

79
class SyncClient(BaseClient):
810
def aclose(self) -> None:

tests/_async/clients.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ def function_client():
2323
"apiKey": mock_access_token(),
2424
"Authorization": f"Bearer {mock_access_token()}",
2525
},
26+
timeout=10,
2627
)

tests/_sync/clients.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ def function_client():
2323
"apiKey": mock_access_token(),
2424
"Authorization": f"Bearer {mock_access_token()}",
2525
},
26+
timeout=10,
2627
)

0 commit comments

Comments
 (0)