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:
@ -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:
|
||||
|
Reference in New Issue
Block a user