I'm running a task in a separate thread where I want to compare groups from one node to groups in another node. However, the 'get_groups' function yields the error "Caller thread can't call this function in this node". I don't think I can use the call_deferred method as it will always return a null value. What is the appropriate way to call a function with returns from another thread?

  • xyz replied to this.
  • tucono Threads can access the API but not all objects/calls are thread-safe. Official documentation clearly states that scene tree is not thread-safe. So in this case the main thread should get the data from the scene tree and pass the reference on to the worker thread.

    tucono Call it from main thread and pass the data to the worker thread.

    So there is no way to request the data from a worker thread using the API? I was hoping to use a separate thread running at a reduced frequency that would be used to update lower-priority information outside the main thread.

    • xyz replied to this.

      tucono Threads can access the API but not all objects/calls are thread-safe. Official documentation clearly states that scene tree is not thread-safe. So in this case the main thread should get the data from the scene tree and pass the reference on to the worker thread.

      Gotcha. I was hoping there was some form of the call_deferred function where I could request access, but it seems not. I'll rework to have data passed from the main thread directly.