Skip to content

Commit 49bb4cf

Browse files
Merge pull request #115 from tgsong/patch-1
Fix runtime_client blocking main thread
2 parents 8db75c5 + 20715b6 commit 49bb4cf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

awslambdaric/lambda_runtime_client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import sys
6+
from concurrent.futures import ThreadPoolExecutor
67
from awslambdaric import __version__
78

89

@@ -68,7 +69,9 @@ def post_init_error(self, error_response_data):
6869
raise LambdaRuntimeClientError(endpoint, response.code, response_body)
6970

7071
def wait_next_invocation(self):
71-
response_body, headers = runtime_client.next()
72+
with ThreadPoolExecutor() as e:
73+
fut = e.submit(runtime_client.next)
74+
response_body, headers = fut.result()
7275
return InvocationRequest(
7376
invoke_id=headers.get("Lambda-Runtime-Aws-Request-Id"),
7477
x_amzn_trace_id=headers.get("Lambda-Runtime-Trace-Id"),

0 commit comments

Comments
 (0)