Lambda函数运行没有错误,但是没有任何反应

时间:2019-09-10 08:30:49

标签: python file-upload lambda slack slack-api

我编写了一个lambda函数,该函数从url下载文件,然后将该文件上传到松弛状态,如下所示:

job.py

from botocore.vendored import requests
import urllib.request
import time


def execute():
    params = {'token': 'my-slack-token',
              'channels': 'test-channel', 'initial_comment': 'test-comment'}

    date = time.strftime("%Y%m%d")

    file_name = "/tmp/" + "file_name" + date + ".xlsx"
    urllib.request.urlretrieve(
        'http://download-url', file_name)
    file = {'file': open(file_name, 'rb')}
    requests.post(url="https://slack.com/api/files.upload", params=params, files=file)

main.py

import job


def execute(event, context):
    job.execute()
    return {
        'statusCode': 200,
        'body': "Done!"
    }

当cloudwatch触发此lambda时,该函数运行正常,没有错误,但没有任何反应。网址中的文件仍未上传到松弛状态。 什么地方出了错? 当我在本地PC上尝试此操作时,文件将上传到正常状态,但是在lambda中则什么也没有发生。

已更新: 当我在CloudWatch中检查日志时,如下所示:

START RequestId: a5ff4b71-4762-4c2a-badd-5be9f8ece494 Version: $LATEST
END RequestId: a5ff4b71-4762-4c2a-badd-5be9f8ece494
REPORT RequestId: a5ff4b71-4762-4c2a-badd-5be9f8ece494  Duration: 568.63 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 25 MB  Init Duration: 142.49 ms    
XRAY TraceId: 1-5d77648c-5a6bf1079e4e6533b58ecd84   SegmentId: 3114b6ac2c50c17d Sampled: false  

0 个答案:

没有答案
相关问题