Threading problems with sensor device

I have connected a sensor and am reading the values within a phyton script.
This script is based on an external library and contains a method that gives me a value as soon as the sensor changes (update rate of 200ms).

Now I have to pass this value to a node TD, but I get threading problems as soon as I do this.

Can anyone tell me something about this and how do I get my value from the sensorChange method into the TD value without creating threading issues?

Thanks a lot!

You need to pass your value to the main thread using something like:

In your worker thread you put the value into that queue, then in a Execute DAT or some DAT script you pull the value off of that queue and apply it to the node however you need (set it’s parameter value etc).

Thanks Malcom, I will check that out

There’s an example of threading in TouchDesigner using a queue here:

This builds on a larger conversation in an old thread here:

2 Likes