Skip to content

Commit

Permalink
Fix timeouts for invocations on the command line.
Browse files Browse the repository at this point in the history
When we use the chalice app in tests, we override the timeout.  When we use the chalice app on lambda, the timeout is valid.

However, in the current version of chalice we're using, calling `get_remaining_time_in_millis()` throws an exception when not run in a lambda.  If we get something unexpected (0 or None), we default to sys.maxsize.
  • Loading branch information
Tony Tung committed Oct 17, 2017
1 parent c75b94a commit 79b1d78
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions chalice/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ def wrapper(*args, **kwargs):
future = executor.submit(method, *args, **kwargs)
time_remaining_s = chalice_app._override_exptime_seconds # type: typing.Optional[float]
if time_remaining_s is None:
time_remaining_s = min(
API_GATEWAY_TIMEOUT_SECONDS,
chalice_app.lambda_context.get_remaining_time_in_millis() / 1000)
try:
lambda_timeout_millis = chalice_app.lambda_context.get_remaining_time_in_millis()
except:
lambda_timeout_millis = sys.maxsize
time_remaining_s = min(API_GATEWAY_TIMEOUT_SECONDS, lambda_timeout_millis / 1000)
time_remaining_s = max(0.0, time_remaining_s - EXECUTION_TERMINATION_THRESHOLD_SECONDS)

try:
Expand Down

0 comments on commit 79b1d78

Please sign in to comment.