diff --git a/awslambdaric/lambda_runtime_client.py b/awslambdaric/lambda_runtime_client.py index 2066f6c..b268abc 100644 --- a/awslambdaric/lambda_runtime_client.py +++ b/awslambdaric/lambda_runtime_client.py @@ -5,6 +5,7 @@ import http import http.client import sys +from concurrent.futures import ThreadPoolExecutor from awslambdaric import __version__ @@ -65,7 +66,9 @@ def post_init_error(self, error_response_data): raise LambdaRuntimeClientError(endpoint, response.code, response_body) def wait_next_invocation(self): - response_body, headers = runtime_client.next() + with ThreadPoolExecutor() as e: + fut = e.submit(runtime_client.next) + response_body, headers = fut.result() return InvocationRequest( invoke_id=headers.get("Lambda-Runtime-Aws-Request-Id"), x_amzn_trace_id=headers.get("Lambda-Runtime-Trace-Id"),