2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Skip ready functions if not in main thread or plugins are not loaded yet

This commit is contained in:
wolflu05
2023-06-08 21:06:14 +00:00
parent f1031efa93
commit e7f546b8b0
7 changed files with 69 additions and 6 deletions

View File

@ -5,7 +5,8 @@ import logging
from django.apps import AppConfig
from django.db.utils import OperationalError, ProgrammingError
from InvenTree.ready import canAppAccessDatabase
from InvenTree.ready import (canAppAccessDatabase, isInMainThread,
isPluginRegistryLoaded)
logger = logging.getLogger('inventree')
@ -17,6 +18,11 @@ class UsersConfig(AppConfig):
def ready(self):
"""Called when the 'users' app is loaded at runtime"""
# skip loading if plugins are not loaded or we run in a background thread
if not isPluginRegistryLoaded() or not isInMainThread():
return
if canAppAccessDatabase(allow_test=True):
try: