简体   繁体   中英

EOFError when deploying google cloud function

I have the following main.py file, that works when created through the website. When I try to do the same by the gcloud, I receive an error about EOFError: EOF when reading a line; Error ID: c84b3231 EOFError: EOF when reading a line; Error ID: c84b3231

The command I'm using is gcloud functions deploy xpto --project=project_xpto --entry-point=xpto --runtime=python39 --source=xpto --trigger-http --vpc-connector=redis --allow-unauthenticated I already tried adding beta to the command, and nothing happens.

My main.py file is that below

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"},
    )

Curiously, while trying to get it to work, I created a new CF with only the code below, and the same gcloud command works

def hello_world(request):
    return "Hello World"

EDIT:

requirements.txt

--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")

Probably its set to CRLF line breaks, you can use dos2unix to convert the script to Unix format

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM