Blender Kitsu: Use Background Thread for Kitsu Login #79

Merged
Nick Alberelli merged 6 commits from fix/blender-kitsu-bg-threading into main 2023-06-16 17:44:21 +02:00
Showing only changes of commit b227d25623 - Show all commits

View File

@ -21,6 +21,7 @@
from typing import Dict, List, Set, Optional, Tuple, Any
import bpy
import threading
from blender_kitsu import cache, prefs, gazu
@ -123,6 +124,12 @@ def auto_login_on_file_open():
if not session.is_auth():
bpy.ops.kitsu.session_start()
# TODO move threading logic into kitsu.session_start() so all logins are BG threaded
def thread_login():
x = threading.Thread(target=auto_login_on_file_open, daemon=True)
# ---------REGISTER ----------.
classes = [
@ -139,7 +146,7 @@ def register():
# it automatically un-registers after it runs.
# FIXME: XXX This makes Blender hang if there is no Internet connectivity
# TODO: Rewrite this, so the 'auto' login happens out of the main thread
bpy.app.timers.register(auto_login_on_file_open, first_interval=0.2)
bpy.app.timers.register(thread_login, first_interval=0.2)
def unregister():