Skip to content

Taipy.gui.invoke long callback

Invoke a long running user callback.

Long-running callbacks are run in a separate thread to not block the application itself.

This function expects to be provided a function to run in the background (in user_function).
It can also be specified a status function that is called when the operation performed by user_function is finished (successfully or not), or periodically (using the period parameter).

See the User Manual section on Long Running Callbacks for details on when and how this function can be used.

Parameters:

Name Type Description Default
state State

The State instance, as received in any callback.

required
user_function Callable[[...], None]

The function that will be run independently of Taipy GUI. Note that this function must not use state, which is not persisted across threads.

required
user_function_args Optional[List | Tuple]

The arguments to send to user_function.

[]
user_status_function Optional(Callable[[State, bool, ...], None]

The optional user-defined status function that is invoked at the end of and possibly during the runtime of user_function:

  • The first parameter of this function is set to a State instance.
  • The second parameter of this function is set to a bool or an int, depending on the conditions under which it is called:

  • If this parameter is set to a bool value, then:

    • If True, this indicates that user_function has finished properly.
    • If False, this indicates that user_function failed.
  • If this parameter is set to an int value, then this value indicates how many periods (as lengthy as indicated in period) have elapsed since user_function was started.

None
user_status_function_args Optional[List | Tuple]

The remaining arguments of the user status function.

[]
period int

The interval, in milliseconds, at which user_status_function is called.
The default value is 0, meaning no call to user_status_function will happen until user_function terminates (then the second parameter of that call will be ).
When set to a value smaller than 500, user_status_function is called only when user_function terminates (as if period was set to 0).

0