Skip to content

Commit 20715b6

Browse files
authored
Fix runtime_client blocking main thread
runtime_client.next is calling into the C extension which blocks the main thread. Moving it to a separate thread enables the main thread to process signal, see this issue for more details: #105
1 parent 2d0c421 commit 20715b6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: awslambdaric/lambda_runtime_client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import http
66
import http.client
77
import sys
8+
from concurrent.futures import ThreadPoolExecutor
89
from awslambdaric import __version__
910

1011

@@ -65,7 +66,9 @@ def post_init_error(self, error_response_data):
6566
raise LambdaRuntimeClientError(endpoint, response.code, response_body)
6667

6768
def wait_next_invocation(self):
68-
response_body, headers = runtime_client.next()
69+
with ThreadPoolExecutor() as e:
70+
fut = e.submit(runtime_client.next)
71+
response_body, headers = fut.result()
6972
return InvocationRequest(
7073
invoke_id=headers.get("Lambda-Runtime-Aws-Request-Id"),
7174
x_amzn_trace_id=headers.get("Lambda-Runtime-Trace-Id"),

0 commit comments

Comments
 (0)