python - 运行 sls deploy 时无服务器挂起。 Docker 命令未结束

标签 python docker serverless

我正在关注 this tutorial为了使用 python 设置无服务器 AWS lambda。
我想使用无服务器 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

现在,如您所见,custom 部分告诉 serverless-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...
然后它就卡住了。知道出了什么问题。我错过了什么吗?

最佳答案

好的,结果一切正常。命令没有挂起,只是需要很多时间。耐心是关键。

关于python - 运行 sls deploy 时无服务器挂起。 Docker 命令未结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64605946/

相关文章:

python - Keras,如何获取每一层的输出?

python - 选择的性能与 randint

python - 使用正则表达式查找模式

Docker SBT 构建卡在 M2 芯片上以部署到 GKE

serverless-framework - 无服务器离线不获取路由

webpack - 无服务器框架功能的 AWS Lambda 文件系统路径?

python - Tensorflow 滑动窗口转换

docker - kubernetes集群无法初始化

node.js - 无法安装 Node 7.5.0

amazon-web-services - 如何获取 Cloud Formation 特定资源属性的 AWS Lambda 函数的 ARN?