Skip to content

Commit

Permalink
feat: add edge functions timeout (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
juancarlospaco authored Jul 21, 2024
1 parent e1d064b commit d0abc3c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion supabase_functions/_async/functions_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class AsyncFunctionsClient:
def __init__(self, url: str, headers: Dict, verify: bool = True):
def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True):
self.url = url
self.headers = {
"User-Agent": f"supabase-py/functions-py v{__version__}",
Expand All @@ -17,6 +17,7 @@ def __init__(self, url: str, headers: Dict, verify: bool = True):
base_url=self.url,
headers=self.headers,
verify=bool(verify),
timeout=timeout,
follow_redirects=True,
http2=True,
)
Expand Down
3 changes: 2 additions & 1 deletion supabase_functions/_sync/functions_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class SyncFunctionsClient:
def __init__(self, url: str, headers: Dict, verify: bool = True):
def __init__(self, url: str, headers: Dict, timeout: int, verify: bool = True):
self.url = url
self.headers = {
"User-Agent": f"supabase-py/functions-py v{__version__}",
Expand All @@ -17,6 +17,7 @@ def __init__(self, url: str, headers: Dict, verify: bool = True):
base_url=self.url,
headers=self.headers,
verify=bool(verify),
timeout=timeout,
follow_redirects=True,
http2=True,
)
Expand Down
2 changes: 2 additions & 0 deletions supabase_functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

__version__ = "0.4.7"

DEFAULT_FUNCTION_CLIENT_TIMEOUT = 5


class SyncClient(BaseClient):
def aclose(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/_async/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ def function_client():
"apiKey": mock_access_token(),
"Authorization": f"Bearer {mock_access_token()}",
},
timeout=10,
)
1 change: 1 addition & 0 deletions tests/_sync/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ def function_client():
"apiKey": mock_access_token(),
"Authorization": f"Bearer {mock_access_token()}",
},
timeout=10,
)

0 comments on commit d0abc3c

Please sign in to comment.