AWS Lambda 中 get_remaining_time_in_millis 的替代方案可用于 Google Cloud Function?
What alternative for get_remaining_time_in_millis in AWS Lambda is available for Google Cloud Function?
我需要在函数超时之前退出我的循环,为此在 AWS Lambda 中我们有 get_remaining_time_in_millis,我通常将其用于此目的。
do {
... // process the tasks in small batches that can be completed in, say, less than 10s
// when there's less than 10s left, stop
} while (context.getRemainingTimeInMillis() > 10000);
在 GCP 中是否有类似的方法来完成相同的任务?我试图避免调用 rest api 来获取函数配置并自己实现它。
firebaser 在这里
我认为 Google Cloud Functions 目前没有公开这样的价值。如果你真的需要这样的东西,你必须自己实现它,记录你的代码第一次启动的时间,并根据你配置的最大 运行 时间跟踪它,你可以通过阅读 FUNCTION_TIMEOUT_SEC
环境变量.
不过这听起来像是一个合理的功能,所以我推荐 filing a feature request。
我需要在函数超时之前退出我的循环,为此在 AWS Lambda 中我们有 get_remaining_time_in_millis,我通常将其用于此目的。
do {
... // process the tasks in small batches that can be completed in, say, less than 10s
// when there's less than 10s left, stop
} while (context.getRemainingTimeInMillis() > 10000);
在 GCP 中是否有类似的方法来完成相同的任务?我试图避免调用 rest api 来获取函数配置并自己实现它。
firebaser 在这里
我认为 Google Cloud Functions 目前没有公开这样的价值。如果你真的需要这样的东西,你必须自己实现它,记录你的代码第一次启动的时间,并根据你配置的最大 运行 时间跟踪它,你可以通过阅读 FUNCTION_TIMEOUT_SEC
环境变量.
不过这听起来像是一个合理的功能,所以我推荐 filing a feature request。