首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >部署谷歌云函数时的EOFError

部署谷歌云函数时的EOFError
EN

Stack Overflow用户
提问于 2021-10-06 01:28:08
回答 1查看 98关注 0票数 0

我有以下main.py文件,当通过网站创建时,工程。当我尝试用gcloud做同样的事情时,我收到一个关于EOFError: EOF when reading a line; Error ID: c84b3231的错误

我正在使用的命令是gcloud functions deploy xpto --project=project_xpto --entry-point=xpto --runtime=python39 --source=xpto --trigger-http --vpc-connector=redis --allow-unauthenticated我已经尝试将beta添加到该命令,但是没有任何反应。

我的main.py文件如下所示

代码语言:javascript
复制
import json
import logging
from datetime import date
from http import HTTPStatus
from flask import Request
import service

setup_logger()
LOGGER = logging.getLogger(__name__)

def xpto(request: Request, token: str):
    LOGGER.info(f"{request.method} accepted.")

    id = get_id(token)

    res_xpto = get_xpto(id=id)

    return make_response(
        json.dumps(res_xpto, default=lambda t: str(t) if isinstance(t, date) else t),
        http_code=HTTPStatus.OK,
        headers={"Content-Type": "application/json"},
    )

奇怪的是,当我尝试让它工作时,我只用下面的代码创建了一个新的CF,同样的gcloud命令也可以工作

代码语言:javascript
复制
def hello_world(request):
    return "Hello World"

编辑:

requirements.txt

代码语言:javascript
复制
--extra-index-url {URL}

cachetools==4.2.2; python_version >= "3.9" and python_version < "4.0"
certifi==2021.5.30; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.0"
cffi==1.14.6; python_version >= "3.9" and python_version < "4.0"
charset-normalizer==2.0.4; python_full_version >= "3.6.0" and python_version >= "3.9" and python_version < "4.0"
click==7.1.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
cloudevents==1.2.0
cryptography==3.4.8; python_version >= "3.9" and python_version < "4.0"
deprecation==2.1.0
flask==1.1.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
functions-framework==2.1.0; python_version >= "3.5" and python_version < "4"
google-api-core==2.0.1; python_version >= "3.9" and python_version < "4.0"
google-auth==2.0.2; python_version >= "3.9" and python_version < "4.0"
google-cloud-secret-manager==2.7.0; python_version >= "3.9" and python_version < "4.0"
googleapis-common-protos==1.53.0; python_version >= "3.9" and python_version < "4.0"
greenlet==1.1.1; python_version >= "3" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3"
grpc-google-iam-v1==0.12.3; python_version >= "3.9" and python_version < "4.0"
grpcio==1.39.0; python_version >= "3.9" and python_version < "4.0"
gunicorn==20.0.4; python_version >= "3.4"
idna==3.2; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_full_version >= "3.6.0" and python_version >= "3.9" and python_version < "4.0"
itsdangerous==1.1.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
jinja2==2.11.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
libcst==0.3.20; python_version >= "3.9" and python_version < "4.0"
markupsafe==1.1.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
mypy-extensions==0.4.3; python_version >= "3.9" and python_version < "4.0"
mysqlclient==2.0.3; python_version >= "3.5"
packaging==21.0; python_version >= "3.9" and python_version < "4.0"
pathtools==0.1.2
phpserialize==1.3
proto-plus==1.19.0; python_version >= "3.9" and python_version < "4.0"
protobuf==3.17.3; python_version >= "3.9" and python_version < "4.0"
pyasn1-modules==0.2.8; python_version >= "3.9" and python_version < "4.0"
pyasn1==0.4.8; python_version >= "3.9" and python_version < "4.0"
pycparser==2.20; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.4.0"
pydantic==1.8.2; python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.1"
pyjwt==2.1.0; python_version >= "3.9" and python_version < "4.0"
pyparsing==2.4.7; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
pyyaml==5.4.1; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.0"
requests==2.26.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
rsa==4.7.2; python_version >= "3.9" and python_version < "4"
six==1.16.0; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.3.0"
sqlalchemy==1.4.22; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
tenacity==7.0.0
typing-extensions==3.10.0.2; python_version >= "3.9" and python_version < "4.0" and python_full_version >= "3.6.1"
typing-inspect==0.7.1; python_version >= "3.9" and python_version < "4.0"
urllib3==1.26.6; python_version >= "3.9" and python_full_version < "3.0.0" and python_version < "4.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.9"
watchdog==1.0.2; python_version >= "3.6"
werkzeug==1.0.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
EN

回答 1

Stack Overflow用户

发布于 2021-10-06 01:31:44

可能是设置为CRLF换行符,您可以使用dos2unix将脚本转换为Unix格式

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69458870

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档