-
Notifications
You must be signed in to change notification settings - Fork 470
Description
So the consumption plan for functions has a default execution timeout of 5 minutes. Its not great to allow your functions to hit this timeout because when it happens, your entire process ends up getting restarted (because its the only way to force the execution to stop - task.Abort() does not exist). This will be disruptive to other long running functions in the same process.
The challenge is that as a function author that is aware of this, there's not much you can do to address it. In the case of C#, you could update your function to take a CancellationToken and check the state of that token (or pass it into async APIs your function is calling). However even if you do this, today the system will still terminate the process (because it does not check to see if your function actually honored the cancellation request).
So, this work item tracks the idea of making the timeout mechanism smarter. It would do the following:
- If the function does not take a cancellation token, no change in behavior (the process will get killed)
- If the function takes a cancellation token, signal the token once the timeout has expired and then wait some period of time (say 5 seconds) and then check to see if the function task has completed. If the task has completed then we assume the timeout was handled gracefully and do not kill the process.
In order for this approach to work for multiple languages, we need a way to support the equivalent of cancellation tokens for out of proc languages which is tracked by #2152.