mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Skip ready functions if not in main thread or plugins are not loaded yet
This commit is contained in:
@ -12,7 +12,8 @@ from django.conf import settings
|
||||
from django.core.exceptions import AppRegistryNotReady
|
||||
from django.db.utils import OperationalError
|
||||
|
||||
from InvenTree.ready import canAppAccessDatabase
|
||||
from InvenTree.ready import (canAppAccessDatabase, isInMainThread,
|
||||
isPluginRegistryLoaded)
|
||||
|
||||
logger = logging.getLogger("inventree")
|
||||
|
||||
@ -35,6 +36,10 @@ class LabelConfig(AppConfig):
|
||||
|
||||
def ready(self):
|
||||
"""This function is called whenever the label app is loaded."""
|
||||
# skip loading if plugins are not loaded or we run in a background thread
|
||||
if not isPluginRegistryLoaded() or not isInMainThread():
|
||||
return
|
||||
|
||||
if canAppAccessDatabase():
|
||||
|
||||
try:
|
||||
|
Reference in New Issue
Block a user