Update leenkx/blender/lnx/handlers.py
This commit is contained in:
parent
c08e1d3835
commit
06319131fd
@ -132,6 +132,7 @@ def always() -> float:
|
|||||||
return 0.5
|
return 0.5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def poll_threads() -> float:
|
def poll_threads() -> float:
|
||||||
"""Polls the thread callback queue and if a thread has finished, it
|
"""Polls the thread callback queue and if a thread has finished, it
|
||||||
is joined with the main thread and the corresponding callback is
|
is joined with the main thread and the corresponding callback is
|
||||||
@ -141,21 +142,27 @@ def poll_threads() -> float:
|
|||||||
thread, callback = make.thread_callback_queue.get(block=False)
|
thread, callback = make.thread_callback_queue.get(block=False)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
return 0.25
|
return 0.25
|
||||||
|
if thread.is_alive():
|
||||||
thread.join()
|
try:
|
||||||
|
make.thread_callback_queue.put((thread, callback), block=False)
|
||||||
try:
|
except queue.Full:
|
||||||
callback()
|
return 0.5
|
||||||
except Exception as e:
|
return 0.1
|
||||||
# If there is an exception, we can no longer return the time to
|
else:
|
||||||
# the next call to this polling function, so to keep it running
|
try:
|
||||||
# we re-register it and then raise the original exception.
|
thread.join()
|
||||||
bpy.app.timers.unregister(poll_threads)
|
callback()
|
||||||
bpy.app.timers.register(poll_threads, first_interval=0.01, persistent=True)
|
except Exception as e:
|
||||||
raise e
|
# If there is an exception, we can no longer return the time to
|
||||||
|
# the next call to this polling function, so to keep it running
|
||||||
# Quickly check if another thread has finished
|
# we re-register it and then raise the original exception.
|
||||||
return 0.01
|
try:
|
||||||
|
bpy.app.timers.unregister(poll_threads)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
bpy.app.timers.register(poll_threads, first_interval=0.01, persistent=True)
|
||||||
|
# Quickly check if another thread has finished
|
||||||
|
return 0.01
|
||||||
|
|
||||||
|
|
||||||
loaded_py_libraries: dict[str, types.ModuleType] = {}
|
loaded_py_libraries: dict[str, types.ModuleType] = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user