【问题标题】:TimeoutAttribute doesn't work for Azure function appTimeoutAttribute 不适用于 Azure 函数应用
【发布时间】:2021-10-27 02:33:02
【问题描述】:

我想限制天蓝色函数的执行时间,并在其上添加了TimeoutAttribute,如下代码。

    [FunctionName("Func2")]
    [Timeout("00:00:02", TimeoutWhileDebugging = true)]
    public static void Run([TimerTrigger("*/5 * * * * *")] TimerInfo myTimer, ILogger log)
    {
        log.LogInformation($"hi...");

        int length = 10;
        for (int i = 0; i < length; i++)
        {
            log.LogInformation($"looping {i + 1}...");
            //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
            System.Threading.Tasks.Task.Delay(3000).Wait();
        }
    }

我在本地的 Visual Studio 2019 中运行了代码。我预计上面的代码会在 2 秒内超时,但它运行了完整的 10 个循环,没有任何错误。

上面有什么问题吗?

【问题讨论】:

标签: c# .net azure azure-functions


【解决方案1】:

这看起来像一个错误并且可以重现,我也可以在本地重现它

Github 问题 #1900

目前正在通过分类进行,并带有错误标签。

注意:现阶段没有已知的解决方法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 2020-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多