2
0
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:
wolflu05
2023-06-08 21:06:14 +00:00
parent f1031efa93
commit e7f546b8b0
7 changed files with 69 additions and 6 deletions

View File

@ -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: