Title: Infer thread polling config from sys version by Stefan9283 · Pull Request #212 · aws/aws-lambda-python-runtime-interface-client · GitHub
Open Graph Title: Infer thread polling config from sys version by Stefan9283 · Pull Request #212 · aws/aws-lambda-python-runtime-interface-client
X Title: Infer thread polling config from sys version by Stefan9283 · Pull Request #212 · aws/aws-lambda-python-runtime-interface-client
Description: Issue #, if available: #105 Description of changes: This change backports the graceful shutdown hooks to Python 3.10, 3.11 (not as relevant for managed given the deprecation date for August 2027) and also custom OCI images (when AWS_EXECUTION_ENV is not defined the default is AWS_Lambda_Image). Target (OCI, Managed Runtime, both): both Testing: Dockerfile.python310 # Python 3.10 Lambda container image using AWS Lambda base image FROM public.ecr.aws/lambda/python:3.10 AS build-image # Install build dependencies RUN yum install -y \ gcc \ gcc-c++ \ make \ cmake3 \ libcurl-devel \ autoconf \ automake \ libtool \ tar \ gzip \ && ln -sf /usr/bin/cmake3 /usr/bin/cmake \ && yum clean all # Build the runtime interface client from local source ARG RIC_BUILD_DIR="/home/build/" RUN mkdir -p ${RIC_BUILD_DIR} WORKDIR ${RIC_BUILD_DIR} COPY . . RUN pip install setuptools RUN make init build RUN mv ./dist/awslambdaric-*.tar.gz ./dist/awslambdaric-test.tar.gz # Copy the function handler ARG FUNCTION_DIR="/var/task" RUN mkdir -p ${FUNCTION_DIR} COPY tests/integration/test-handlers/shutdown-hook/* ${FUNCTION_DIR} # Final stage - clean runtime image FROM public.ecr.aws/lambda/python:3.10 ARG FUNCTION_DIR="/var/task" WORKDIR ${FUNCTION_DIR} # Copy the function code COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR} # Copy the built RIC tarball and install it, overriding the bundled awslambdaric in /var/runtime COPY --from=build-image /home/build/dist/awslambdaric-test.tar.gz /tmp/ RUN yum install -y gcc gcc-c++ make cmake3 libcurl-devel tar gzip autoconf automake libtool && \ ln -sf /usr/bin/cmake3 /usr/bin/cmake && \ rm -rf /var/runtime/awslambdaric* && \ rm -f /var/runtime/runtime_client* && \ pip install /tmp/awslambdaric-test.tar.gz --target /var/runtime && \ rm /tmp/awslambdaric-test.tar.gz && \ yum history undo -y last && yum clean all && rm -rf /var/cache/yum # Install Lambda Insights extension layer (required for graceful shutdown support) # Download manually before building: # curl -f -s -o lambda-insights-amd64-64.zip "$(aws lambda get-layer-version-by-arn --region eu-west-1 --arn "arn:aws:lambda:eu-west-1:580247275435:layer:LambdaInsightsExtension:64" --query 'Content.Location' --output text)" COPY lambda-insights-amd64-64.zip /tmp # hadolint ignore=DL3033 RUN yum install -y unzip && unzip -q -d /opt /tmp/lambda-insights-amd64-64.zip && rm /tmp/*.zip && \ yum history undo -y last && yum clean all && rm -rf /var/cache/yum # Replace AWS_EXECUTION_ENV so the base image's bundled RIC path isn't triggered RUN sed -i 's/export AWS_EXECUTION_ENV=.*/export AWS_EXECUTION_ENV=AWS_Lambda_Image/' /var/runtime/bootstrap CMD [ "app.lambda_handler" ] Handler (tests/integration/test-handlers/shutdown-hook/app.py) - same as the official demo import json import platform import signal import sys import time def exit_gracefully(signum, frame): r""" SIGTERM Handler: https://docs.aws.amazon.com/lambda/latest/operatorguide/static-initialization.html Listening for os signals that can be handled,reference: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html Termination Signals: https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html """ print("[runtime] SIGTERM received") print("[runtime] cleaning up") # perform actual clean up work here. time.sleep(0.2) print("[runtime] exiting") sys.exit(0) signal.signal(signal.SIGTERM, exit_gracefully) def lambda_handler(event, context): return "SUCCESS" Cloudwatch logs Python 3.10 2026-07-02T17:51:39.669+01:00 LOGS Name: cloudwatch_lambda_agent State: Subscribed Types: [Platform] 2026-07-02T17:51:40.201+01:00 EXTENSION Name: cloudwatch_lambda_agent State: Ready Events: [INVOKE, SHUTDOWN] 2026-07-02T17:51:40.208+01:00 START RequestId: be18ce5e-0ef9-4933-917f-ebfc53522ab7 Version: $LATEST 2026-07-02T17:51:40.218+01:00 END RequestId: be18ce5e-0ef9-4933-917f-ebfc53522ab7 2026-07-02T17:51:40.218+01:00 REPORT RequestId: be18ce5e-0ef9-4933-917f-ebfc53522ab7 Duration: 3.36 ms Billed Duration: 642 ms Memory Size: 512 MB Max Memory Used: 39 MB Init Duration: 637.70 ms 2026-07-02T17:57:39.206+01:00 [runtime] SIGTERM received 2026-07-02T17:57:39.206+01:00 [runtime] cleaning up 2026-07-02T17:57:39.406+01:00 [runtime] exiting By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Open Graph Description: Issue #, if available: #105 Description of changes: This change backports the graceful shutdown hooks to Python 3.10, 3.11 (not as relevant for managed given the deprecation date for August 2027) a...
X Description: Issue #, if available: #105 Description of changes: This change backports the graceful shutdown hooks to Python 3.10, 3.11 (not as relevant for managed given the deprecation date for August 2027) a...
Opengraph URL: https://github.com/aws/aws-lambda-python-runtime-interface-client/pull/212
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:96cc0e3b-f514-a9cf-0b78-7956db8d8f9e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E4CC:1F62DD:9F539B:D85AAC:6A62EC0F |
| html-safe-nonce | caea28e606dedd479e8f699de48e969ab8cd1e77315b7535a4356d516c147ed8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNENDOjFGNjJERDo5RjUzOUI6RDg1QUFDOjZBNjJFQzBGIiwidmlzaXRvcl9pZCI6Ijc0MTk2MTAyMjUyOTIwMTI1NTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 66ded3835df28fb06738bca69dcd2a258ac614ec0e4390fd633e16515480a1f5 |
| hovercard-subject-tag | pull_request:3980148685 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/aws/aws-lambda-python-runtime-interface-client/pull/212/files |
| twitter:image | https://avatars.githubusercontent.com/u/34220105?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/34220105?s=400&v=4 |
| og:image:alt | Issue #, if available: #105 Description of changes: This change backports the graceful shutdown hooks to Python 3.10, 3.11 (not as relevant for managed given the deprecation date for August 2027) a... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | df33b1b61ee7b9a0af988199bfc3503c9c1acafb1f1d40e1f140ea7c84f890dd |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/aws/aws-lambda-python-runtime-interface-client git https://github.com/aws/aws-lambda-python-runtime-interface-client.git |
| octolytics-dimension-user_id | 2232217 |
| octolytics-dimension-user_login | aws |
| octolytics-dimension-repository_id | 292411453 |
| octolytics-dimension-repository_nwo | aws/aws-lambda-python-runtime-interface-client |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 292411453 |
| octolytics-dimension-repository_network_root_nwo | aws/aws-lambda-python-runtime-interface-client |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d41cd1bdb290013455c0ac430fa755621733f5eb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width