In my blender python script I have a function which reads data from a serial port then moves the position of an object based on that data.

I use bpy.app.timers.register to loop the function every 0.01 seconds. It needs to run frequently in order to update the position in realtime.

Blender is noticably slower when this is running (such as if you move the view around).

I suspect bpy.app.timers is running on the main thread and blocking other core functions.

Is there a way to run the loop on a background or low priority thread so that it does not interfere at all with blender core performance?


1 Answer 1


After more research it appears that yes bpy.app.timers.register processes are running on the main Blender thread. So any data processing should be done outside the timer function.

Instead I have moved my serial data reading into a separate Thread using:

thread = threading.Thread(target=read_serial, daemon=True)

Inside this new thread function it will read/process the data and put it into a variable. The timer function can then just access the variable and update the object position.

Now Blender runs smoothly while the timer and thread are running.

Note that reason for using both a Thread and a Timer (instead of just using the Thread to do everything), is so that the thread is not trying to manipulate Blender objects while the main Blender thread is also accessing them; which could lead to errors.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .