Trying to run my serverless python lambda functions locally using:
serverless invoke local -f hello
The function runs, but it seems to take 2-5 seconds before the handler is called. This is a real issue for me as I'm hoping to use invoke to support local testing.
My handler is super simple:
def hello(event, context):
print('start')
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": event
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
print('end')
return response
Rough timings:
- calling
invoketoprint(start): 2-5s print(start)toprint(end): <0.5sprint(end)to response returning to terminal: 1s
Since I cant find any other people with this issue, suggests its something to do with my local machine. No idea what it could be or even where to start fault finding.
Serverless: 1.32 (globally installed) Python: 3.6.5