Skip to content

Commit

Permalink
Merge pull request #579 from ttung/tonytung-timeout
Browse files Browse the repository at this point in the history
Scale the lambda_timeout parameter correctly.
  • Loading branch information
jamesls authored Nov 16, 2017
2 parents 3caf032 + 934a6ca commit 3503c2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion chalice/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,14 @@ def __init__(self, app_object, config):

def _generate_lambda_context(self):
# type: () -> LambdaContext
if self._config.lambda_timeout is None:
timeout = None
else:
timeout = self._config.lambda_timeout * 1000
return LambdaContext(
function_name=self._config.function_name,
memory_size=self._config.lambda_memory_size,
max_runtime_ms=self._config.lambda_timeout
max_runtime_ms=timeout
)

def _generate_lambda_event(self, method, path, headers, body):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ def context_view():
assert body['name'] == 'api_handler'
assert body['memory'] == 256
assert body['version'] == '$LATEST'
assert body['timeout'] <= 10
assert body['timeout'] > 10
assert body['timeout'] <= 10000
assert AWS_REQUEST_ID_PATTERN.match(body['request_id'])

def test_can_validate_route_with_variables(self, demo_app_auth):
Expand Down

0 comments on commit 3503c2e

Please sign in to comment.