Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add touch_try_count and raise RequestException #1808

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ to change Zappa's behavior. Use these at your own risk!
"timeout_seconds": 30, // Maximum lifespan for the Lambda function (default 30, max 900.)
"touch": true, // GET the production URL upon initial deployment (default True)
"touch_path": "/", // The endpoint path to GET when checking the initial deployment (default "/")
"touch_try_count": 4, // Requests try count if requests return 504 when checking the initial deployment (default 4)
"use_precompiled_packages": true, // If possible, use C-extension packages which have been pre-compiled for AWS Lambda. Default true.
"vpc_config": { // Optional Virtual Private Cloud (VPC) configuration for Lambda function
"SubnetIds": [ "subnet-12345678" ], // Note: not all availability zones support Lambda!
Expand Down
9 changes: 5 additions & 4 deletions zappa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2690,12 +2690,13 @@ def touch_endpoint(self, endpoint_url):
# ready and requests will return 504 status_code until ready.
# So, if we get a 504 status code, rerun the request up to 4 times or
# until we don't get a 504 error
if req.status_code == 504:
check_status_code = 504
if req.status_code == check_status_code:
i = 0
status_code = 504
while status_code == 504 and i <= 4:
touch_try_count = self.stage_config.get('touch_try_count', 4)

while req.status_code == check_status_code and i <= touch_try_count:
req = requests.get(endpoint_url + touch_path)
status_code = req.status_code
i += 1

if req.status_code >= 500:
Expand Down
6 changes: 4 additions & 2 deletions zappa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ def splitpath(path):
print(" - sqlite==python36: Using precompiled lambda package")
self.extract_lambda_package('sqlite3', temp_project_path)

except requests.exceptions.RequestException as e:
print(e)
raise e
except Exception as e:
print(e)
# XXX - What should we do here?
Expand Down Expand Up @@ -815,7 +818,7 @@ def download_url_with_progress(url, stream, disable_progress):
Downloads a given url in chunks and writes to the provided stream (can be any io stream).
Displays the progress bar for the download.
"""
resp = requests.get(url, timeout=2, stream=True)
resp = requests.get(url, timeout=3, stream=True)
resp.raw.decode_content = True

progress = tqdm(unit="B", unit_scale=True, total=int(resp.headers.get('Content-Length', 0)), disable=disable_progress)
Expand Down Expand Up @@ -1987,7 +1990,6 @@ def stack_outputs(self, name):
except botocore.client.ClientError:
return {}


def get_api_url(self, lambda_name, stage_name):
"""
Given a lambda_name and stage_name, return a valid API URL.
Expand Down