Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can an exception be thrown if the processing time on the timer is too long? #9142

Open
kengiczhangchao opened this issue Sep 20, 2024 · 4 comments

Comments

@kengiczhangchao
Copy link

Can an exception be thrown if the processing time on the timer is too long.

Settings similar to the following
.Configure(options =>
{
options.ResponseTimeout = TimeSpan.FromSeconds(30);
})

@ReubenBond
Copy link
Member

@kengiczhangchao there is no response for a timer execution, so there would be nothing to catch the exception. This is true for timers in .NET in general: there is no call site in user code where the exception can be propagated to.

Given the above, what would you like to see in the case that a timer callback exceeds its time limit? It should be straightforward to implement something.

@kengiczhangchao
Copy link
Author

@kengiczhangchao there is no response for a timer execution, so there would be nothing to catch the exception. This is true for timers in .NET in general: there is no call site in user code where the exception can be propagated to.

Given the above, what would you like to see in the case that a timer callback exceeds its time limit? It should be straightforward to implement something.
I hope throw an exception when a task is executed too long time in callback and then continue with the next callback instead of waiting all the time,The grain seems to be dead,And the program doesn't know what went wrong。

@kengiczhangchao
Copy link
Author

@ReubenBond

@ReubenBond
Copy link
Member

@kengiczhangchao could you show me roughly what the timer task is doing? If it is running forever, that is a problem. Grains are single-threaded and cancellation in .NET is cooperative (the callee must check the CancellationToken themselves), so it cannot just abandon a long-running operation and let it keep going without the operation cooperating. Does that make sense? Otherwise, the task could keep going in the background. If we stopped the task from executing altogether, then any resources which it holds (eg, locks/semaphores) will not be released. This is why it is not valid in .NET to abandon a running method, because catch/finally/cleanup blocks would not be executed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants