aws / aws-lambda-python-runtime-interface-client

Apache License 2.0
255 stars 72 forks source link

Lazily initialize http modules used for error handling #121

Closed alex-pewpew closed 9 months ago

alex-pewpew commented 9 months ago

Implicit import ssl is happening here: https://github.com/python/cpython/blob/main/Lib/http/client.py#L1431

http.client is only used to report a case of thrown Exception during init. It's not a general execution path, and it's not time-critical. Thus it makes sense to speed up cold starts by importing on-demand

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.