return from func intervall in sequence


is it possible to get a return value from a function which is started as a func interval in a sequence?

Function intervals are only called once, so just set a global value when it completes, instead of returning it.

def funcinterval( ):
   global funcinterval_return
   funcinterval_return = "xyz"

There are other methods too, such as passing a unique key as argument to assign to in a dictionary, appending to a list, assigning to a pre-determined key in a unique dictionary passed as a parameter, or passing a bound method to ‘Func’ and getting an object as a parameter (similar to the unique dictionary).

Most intervals have no single return value since they are called multiple times. However, even in the case of a function interval, which is called only once, while it has a defined return value, it has no place to return control to; since the statement that created the chain of events completes before the function interval is called.

In the future Panda and similar event frameworks could create a structure that holds the result of chains of functions that mirrors the chains’ structures, similar to multiprocessing IIRC. That is, you could get the return value after the function interval completes by querying the framewark.

What do you want to do with the return value? Nothing in the Interval manager will be expecting a return value. So who do you expect to receive it and process it?

You can certainly wrap your function in another function that calls your function and does something appropriate with the return value. Or, you can store your “return value” in a global value or an instance member for your inspection later. Or, you can have your function call another function and pass the “return value” to that function.

But simply returning it means nothing, because the interval player that called your function won’t know what to do with it.


ok, thanks