开发者社区> 问答> 正文

使用函数计算调用表格存储一直time out

新手第一次用阿里云的产品。在函数计算写代码获取表格存储的数据,执行日志一直显示timeout,函数执行状态函数执行失败(UnhandledInvocationError)。

函数计算里的代码:

-- coding: utf-8 --

import datetime
from tablestore import *

INSTANCE_NAME = 'WLQC2019'
REGION = 'cn-shanghai'
ENDPOINT = 'https://%s.%s.ots-internal.aliyuncs.com'%(INSTANCE_NAME, REGION)
TABLENAME = 'T_User'

def get_ots_client(context):
creds = context.credentials
client = OTSClient(ENDPOINT, creds.accessKeyId, creds.accessKeySecret, INSTANCE_NAME, sts_token = creds.securityToken)
return client

def handler(event, context):
CardID = "AB45TG7HT3"
primary_key = [('CardID',CardID)]
columns_to_get = []

client = get_ots_client(context)

now = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
cond = CompositeColumnCondition(LogicalOperator.AND)
cond.add_sub_condition(SingleColumnCondition("StartTime", now, ComparatorType.LESS_EQUAL ))
cond.add_sub_condition(SingleColumnCondition("EndTime", now, ComparatorType.GREATER_EQUAL ))

consumed, return_row, next_token = client.get_row(TABLENAME, primary_key, columns_to_get)
return return_row.primary_key

执行日志
bject at 0x7f830a18cd10>, 'Connection to wlqc2019.cn-shanghai.ots-internal.aliyuncs.com timed out. (connect timeout=50)')': /GetRow

展开
收起
游客pdvlbctrwqtt2 2019-04-25 21:53:27 4392 0
1 条回答
写回答
取消 提交回答
  • 函数最长运行时间为 10 min,如果您函数的运行时间远大于 10 min,建议您将大函数拆分成几个小函数独立运行。如果您的函数运行时间稍大于 10 min 但不超过 15 min,且很难拆分,可以 联系我们 为您调大限制。

    2019-07-17 23:34:17
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
SAE 引领应用步入 Serverless 全托管新时代 立即下载
Serverless 开发速查手册 立即下载
函数计算集团规模化落地实践(3).ppt 立即下载