fix lease issue (#12828)

This commit is contained in:
Matthias Mair
2026-09-09 07:15:05 +10:00
committed by GitHub
parent 7cd74eecd4
commit 97f7c039c9
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -14,7 +14,7 @@ echo "# POI01| Importing functions"
echo "# POI01| Functions imported" echo "# POI01| Functions imported"
# Envs that should be passed to setup commands # Envs that should be passed to setup commands
export SETUP_ENVS=PATH,APP_HOME,INVENTREE_MEDIA_ROOT,INVENTREE_STATIC_ROOT,INVENTREE_BACKUP_DIR,INVENTREE_PLUGINS_ENABLED,INVENTREE_PLUGIN_FILE,INVENTREE_CONFIG_FILE,INVENTREE_SECRET_KEY_FILE,INVENTREE_DB_ENGINE,INVENTREE_DB_NAME,INVENTREE_DB_USER,INVENTREE_DB_PASSWORD,INVENTREE_DB_HOST,INVENTREE_DB_PORT,INVENTREE_ADMIN_USER,INVENTREE_ADMIN_EMAIL,INVENTREE_ADMIN_PASSWORD,INVENTREE_SITE_URL,SETUP_NGINX_FILE,SETUP_ADMIN_PASSWORD_FILE,SETUP_NO_CALLS,SETUP_DEBUG,SETUP_EXTRA_PIP,SETUP_PYTHON,SETUP_ADMIN_NOCREATION export SETUP_ENVS=PATH,APP_HOME,INVENTREE_MEDIA_ROOT,INVENTREE_STATIC_ROOT,INVENTREE_BACKUP_DIR,INVENTREE_PLUGINS_ENABLED,INVENTREE_PLUGIN_FILE,INVENTREE_CONFIG_FILE,INVENTREE_SECRET_KEY_FILE,INVENTREE_DB_ENGINE,INVENTREE_DB_NAME,INVENTREE_DB_USER,INVENTREE_DB_PASSWORD,INVENTREE_DB_HOST,INVENTREE_DB_PORT,INVENTREE_ADMIN_USER,INVENTREE_ADMIN_EMAIL,INVENTREE_ADMIN_PASSWORD,INVENTREE_SITE_URL,SETUP_NGINX_FILE,SETUP_ADMIN_PASSWORD_FILE,SETUP_NO_CALLS,SETUP_DEBUG,SETUP_EXTRA_PIP,SETUP_PYTHON,SETUP_ADMIN_NOCREATION,SETUP_INITIALIZING
# Get the envs # Get the envs
detect_local_env detect_local_env
@@ -31,6 +31,7 @@ export SETUP_ADMIN_NOCREATION=${SETUP_ADMIN_NOCREATION:-false}
# SETUP_DEBUG can be set to get debug info # SETUP_DEBUG can be set to get debug info
# SETUP_EXTRA_PIP can be set to install extra pip packages # SETUP_EXTRA_PIP can be set to install extra pip packages
# SETUP_PYTHON can be set to use a different python version # SETUP_PYTHON can be set to use a different python version
export SETUP_INITIALIZING=1
# get base info # get base info
detect_ip detect_ip
@@ -59,6 +60,7 @@ if [ "${SETUP_CONF_LOADED}" = "true" ]; then
set_env set_env
fi fi
set_site set_site
export SETUP_INITIALIZING=0
start_inventree start_inventree
# show info # show info
+5
View File
@@ -4,6 +4,7 @@ Used to serialize an potentially long-running operation,
without holding a database transaction open for the duration. without holding a database transaction open for the duration.
""" """
import os
import time import time
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Optional from typing import Optional
@@ -81,6 +82,10 @@ def acquire_lease_blocking(
""" """
deadline = time.monotonic() + timeout deadline = time.monotonic() + timeout
if os.environ.get('SETUP_INITIALIZING', '0') == '1':
logger.debug("Skipping lease acquisition for '%s' during initialization", key)
return True
while True: while True:
if try_acquire_lease(key): if try_acquire_lease(key):
return True return True