云功能HTTP触发器崩溃

时间:2020-05-01 04:38:29

标签: python-3.x google-cloud-firestore google-cloud-functions google-cloud-storage

我编写了一个HTTP触发器,该触发器使用ECG数据库名称并将no记录为参数,并从Cloud Storage中读取记录,计算参数并将其写入Firestore。我观察到一个非常奇怪的事情,代码崩溃,但未在控制台中指出原因。这就是我在控制台中得到的所有内容:

函数执行花费了58017毫秒,状态为:“崩溃”。

通常在从Cloud Storage读取记录时停止。我正在使用MIT-BIH Cloud Storage读取记录。

from google.cloud import storage
from flask import escape
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
import numpy as np
import os
from pathlib import Path
from os import listdir
from os.path import isfile, join
from random import randint

def GCFname(request):
    recordno = request.args['recordno']
    database = request.args['database']

    client = storage.Client()
    bucket = client.get_bucket('bucket_name')

    # it crashes here
    record = wfdb.rdrecord(recordno, channels=[0],pb_dir='mitdb')
    sig = record.p_signal[:,0] 
    test_qrs = processing.gqrs_detect(record.p_signal[:,0], fs=record.fs)

    ann_test= wfdb.rdann(recordno, 'atr',pb_dir='mitdb')

    ##Calculate Parameters

    cred = credentials.ApplicationDefault()
    firebase_admin.initialize_app(cred, {
    'projectId': 'project_name',
    })

    db = firestore.client()

    doc_ref = db.collection('xyz').document(database).collection('abc').document(recordno)
doc_ref.set({
    u'fieldname': fieldvalue
  })

我已经使用gcloud进行了部署, gcloud functions deploy GCFname --runtime python37 --trigger-http --allow-unauthenticated --timeout 540s

但是在使用相同的URL之后会起作用。这可能是什么原因?它绝对不是超时问题。

1 个答案:

答案 0 :(得分:2)

很难理解为什么Cloud Function在没有日志的情况下崩溃,原因可能很多。当前,在清除日志条目或将任何错误跟踪写入Stackdriver之前,Cloud Functions崩溃已打开一个错误。您可以在此处使用此问题跟踪工具进行任何更新:https://issuetracker.google.com/155215191