【问题标题】:How to exit early from a Google Cloud Function如何提前退出 Google Cloud 功能
【发布时间】:2021-01-11 00:31:24
【问题描述】:

如果我在代码中提到的保留已经退出,我必须退出我的 Python 代码。我正在尝试使用以下代码,但它不起作用:

res_api = ReservationServiceClient()
if res_api.get_reservation(name=myreservation):
    sys.exit(0)
else:

【问题讨论】:

    标签: python google-cloud-platform google-bigquery google-cloud-functions


    【解决方案1】:

    您只需return 即可提前退出云功能:

    res_api = ReservationServiceClient()
    if res_api.get_reservation(name=myreservation):
        return 'OK'
    

    不要使用sys.exit(O),因为这会阻止请求完成。

    【讨论】:

    • 您好,我不确定ReservationServiceClientres_api.get_reservation 是什么,您需要创建一个更详细的新问题。
    猜你喜欢
    • 2011-03-20
    • 1970-01-01
    • 1970-01-01
    • 2018-11-17
    • 1970-01-01
    • 2012-11-09
    • 2020-01-06
    • 2021-11-04
    • 2021-01-30
    相关资源
    最近更新 更多