我跟踪本教程是为了用python设置无服务器的AWS。
我想使用无服务器的lambda运行这个简单的httprequest函数(驻留在httprequest.py中):
import requests
def handler(event, context):
r = requests.get("https://news.ycombinator.com/news")
return {"content": r.text}以下是我的serveless.yaml:
service: serverlessProj
frameworkVersion: '2'
provider:
name: aws
runtime: python3.8
functions:
hello:
handler: hello.handler
httprequest:
handler: httprequest.handler
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: true现在,如您所见,自定义部分告诉无服务器的Python -requirements插件在Docker容器中编译Python包。它应该安装在requirements.txt中的插件。这是requirements.txt的内容:
requests当运行sls deploy时,这是控制台输出:
Serverless: Generated requirements from /Users/user/Desktop/ShoeSwiper/Serverless/requirements.txt in /Users/user/Desktop/ShoeSwiper/Serverless/.serverless/requirements.txt...
Serverless: Installing requirements from /Users/user/Library/Caches/serverless-python-requirements/007/requirements.txt ...
Serverless: Docker Image: lambci/lambda:build-python3.8
Serverless: Using download cache directory /Users/user/Library/Caches/serverless-python-requirements/downloadCacheslspyc
Serverless: Running docker run --rm -v /Users/user/Library/Caches/serverless-python-requirements/007\:/var/task\:z -v /Users/user/Library/Caches/serverless-python-requirements/downloadCacheslspyc\:/var/useDownloadCache\:z -u 0 lambci/lambda\:build-python3.8 python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache...然后它就被卡住了。知道是怎么回事吗。我是不是遗漏了什么?
发布于 2020-10-30 11:30:17
好吧,结果一切都正常。命令没有挂起,只是花了很多时间。耐心是关键。
https://stackoverflow.com/questions/64605946
复制相似问题