Hello,
I’m having problems with my 1st AWS lambda function in python (zip file) that give me the following error: Phase: invoke Status: timeout
.
Not very informative, but after various tests, the source of the error is the importation of a sub-module.
My function imports:
import json
import phonenumbers as pn # version 8.13.30
from phonenumbers import geocoder as gc
The timeout error comes from
from phonenumbers import geocoder as gc
, which is for me perfectly correct.
When I comment this line, the function runs correctly, except the command that uses geocoder (obviously) and gives errors catch by “except” statements.
The phonenumbers lib was installed in AWS CloudShell (pip install phonenumbers, namely phonenumbers-8.13.30-py2.py3-none-any.whl), all __pycache__
removed, Lambda has 644 permissions and 755 permissions for directories.
Zip file architecture:
my_function
|- phonenumbers
|- ...
|- geocoder.py
|- ...
|- lambda_function.py
|- data.json
The function works like a charm without error in AWS CloudShell python command line (importing my locally installed phonenumbers). But not in AWS Lambda!
The only line that uses geocoder (gc) is:
gc.description_for_number(CallerID_determined_pn, "en")
I tried many things, including not import geocoder and using pn.geocoder.description_for_number
but it gives error: AttributeError: module 'phonenumbers' has no attribute 'geocoder'
.
I’m running out of ideas and any advice or solution would be more than welcome.
Best,
Lionel