From a010c1c8b801c07fbfb976eaf1bf391b3f3a42eb Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 30 May 2025 09:15:36 +0200 Subject: [PATCH] Python Docs: remove example for using timers with separate threads This appears to be unreliable. Resolves #139602. --- doc/python_api/examples/bpy.app.timers.5.py | 28 --------------------- 1 file changed, 28 deletions(-) delete mode 100644 doc/python_api/examples/bpy.app.timers.5.py diff --git a/doc/python_api/examples/bpy.app.timers.5.py b/doc/python_api/examples/bpy.app.timers.5.py deleted file mode 100644 index 9770c84d4be..00000000000 --- a/doc/python_api/examples/bpy.app.timers.5.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -Use a Timer to react to events in another thread ------------------------------------------------- - -You should never modify Blender data at arbitrary points in time in separate threads. -However you can use a queue to collect all the actions that should be executed when Blender is in the right state again. -Pythons `queue.Queue` can be used here, because it implements the required locking semantics. -""" -import bpy -import queue - -execution_queue = queue.Queue() - - -# This function can safely be called in another thread. -# The function will be executed when the timer runs the next time. -def run_in_main_thread(function): - execution_queue.put(function) - - -def execute_queued_functions(): - while not execution_queue.empty(): - function = execution_queue.get() - function() - return 1.0 - - -bpy.app.timers.register(execute_queued_functions)