Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format changes to fix build failure.
  • Loading branch information
Pushkar Chawda
Pushkar Chawda committed Oct 27, 2023
commit 63cf68b26e01542784b044f05f49ef185f32d9cb
8 changes: 6 additions & 2 deletions awslambdaric/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,9 @@ def run(app_root, handler, lambda_runtime_api_addr):
sys.stdout = Unbuffered(sys.stdout)
sys.stderr = Unbuffered(sys.stderr)

use_thread_for_polling_next = os.environ.get("AWS_EXECUTION_ENV") == "AWS_Lambda_python3.12"
use_thread_for_polling_next = (
os.environ.get("AWS_EXECUTION_ENV") == "AWS_Lambda_python3.12"
)

with create_log_sink() as log_sink:
lambda_runtime_client = LambdaRuntimeClient(lambda_runtime_api_addr)
Expand All @@ -481,7 +483,9 @@ def run(app_root, handler, lambda_runtime_api_addr):
sys.exit(1)

while True:
event_request = lambda_runtime_client.wait_next_invocation(use_thread_for_polling_next)
event_request = lambda_runtime_client.wait_next_invocation(
use_thread_for_polling_next
)

_GLOBAL_AWS_REQUEST_ID = event_request.invoke_id

Expand Down
6 changes: 3 additions & 3 deletions awslambdaric/lambda_runtime_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
from awslambdaric import __version__


def _user_agent():
py_version = (
f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
Expand Down Expand Up @@ -72,16 +73,15 @@ def wait_next_invocation(self, use_thread_for_polling_next=False):
if use_thread_for_polling_next:
from concurrent.futures import ThreadPoolExecutor
Comment thread
pushkarchawda marked this conversation as resolved.
Outdated
from .lambda_runtime_exception import FaultException
Comment thread
pushkarchawda marked this conversation as resolved.
Outdated

try:
with ThreadPoolExecutor(max_workers=1) as executor:
future = executor.submit(runtime_client.next)
response_body, headers = future.result()
except Exception as e:
raise FaultException(
FaultException.LAMBDA_RUNTIME_CLIENT_ERROR,
"LAMBDA_RUNTIME Failed to get next invocation: {}".format(
str(e)
),
"LAMBDA_RUNTIME Failed to get next invocation: {}".format(str(e)),
None,
)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lambda_runtime_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_wait_next_invocation(self, mock_runtime_client):
self.assertEqual(event_request.content_type, "application/json")
self.assertEqual(event_request.event_body, response_body)

#Using ThreadPoolExecutor to polling next()
# Using ThreadPoolExecutor to polling next()
use_thread_for_polling_next = False
event_request = runtime_client.wait_next_invocation(use_thread_for_polling_next)

Expand Down