How to stop a running function call without using yielding and extra return statements?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NullPointer

Hi, how to stop a running function call without using yielding and extra return statements?

On my scenario i call custom functions e.g. loaded by a external script.

To call the function i do yust instance.call(<func_name>)
But the function can take time and i want to stop it (kill) after an amount of time.
Writing the timer code is not the problem, just how to stop current exection.

Again! Please note I have no influence to the source of executed function it is a customer written code.

Second issue is to stop the function when calling a special function, without using return statements.
This is typical do by using exceptions, but i found no way or equivalence for GdScripts.

I would be very nice to give me some tricks to achive it.

:bust_in_silhouette: Reply From: yrtv

In GDSript no. In C# Maybe if you run it in thread.

WARNING

  1. Killing function execution is not safe.
  2. Thread.Abort is deprecated by Microsoft because it works only on Windows.