mirror of
https://github.com/inventree/InvenTree.git
synced 2026-02-25 16:17:58 +00:00
[bug] fix short-circuit for isGeneratingSchema (#11378)
* [bug] fix short-circuit for isGeneratingSchema * Additional exclusions * Even more exclusions * More exclusions * Updated comment
This commit is contained in:
@@ -86,6 +86,11 @@ def isRunningBackup():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def isCollectingPlugins():
|
||||||
|
"""Return True if the 'collectplugins' command is being executed."""
|
||||||
|
return 'collectplugins' in sys.argv
|
||||||
|
|
||||||
|
|
||||||
def isGeneratingSchema():
|
def isGeneratingSchema():
|
||||||
"""Return true if schema generation is being executed."""
|
"""Return true if schema generation is being executed."""
|
||||||
if isInServerThread() or isInWorkerThread():
|
if isInServerThread() or isInWorkerThread():
|
||||||
@@ -103,6 +108,26 @@ def isGeneratingSchema():
|
|||||||
if isWaitingForDatabase():
|
if isWaitingForDatabase():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
if isCollectingPlugins():
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Additional set of commands which should not trigger schema generation
|
||||||
|
excluded_commands = [
|
||||||
|
'compilemessages',
|
||||||
|
'createsuperuser',
|
||||||
|
'clean_settings',
|
||||||
|
'collectstatic',
|
||||||
|
'makemessages',
|
||||||
|
'wait_for_db',
|
||||||
|
'gunicorn',
|
||||||
|
'qcluster',
|
||||||
|
'check',
|
||||||
|
'shell',
|
||||||
|
]
|
||||||
|
|
||||||
|
if any(cmd in sys.argv for cmd in excluded_commands):
|
||||||
|
return False
|
||||||
|
|
||||||
if 'schema' in sys.argv:
|
if 'schema' in sys.argv:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -111,7 +136,7 @@ def isGeneratingSchema():
|
|||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
# We should only get here if we *are* generating schema
|
# We should only get here if we *are* generating schema
|
||||||
# Any other time this is called, it should be from a server thread, worker thread, or test mode
|
# Raise a warning, so that deevlopers can add extra checks above
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|||||||
Reference in New Issue
Block a user