fix: subprocess not imported in _do_apply background thread
The apply_pending_config endpoint spawns _do_apply in a background thread. subprocess was used but not imported inside the closure, causing NameError: name 'subprocess' is not defined on every Apply click — silently swallowed, so containers never restarted and no error was shown. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -712,14 +712,15 @@ def apply_pending_config():
|
|||||||
# Run in a background thread; 0.3 s delay lets Flask send this response first.
|
# Run in a background thread; 0.3 s delay lets Flask send this response first.
|
||||||
def _do_apply():
|
def _do_apply():
|
||||||
import time as _time
|
import time as _time
|
||||||
|
import subprocess as _subprocess
|
||||||
_time.sleep(0.3)
|
_time.sleep(0.3)
|
||||||
if compose_down_args:
|
if compose_down_args:
|
||||||
r = subprocess.run(base_cmd + compose_down_args,
|
r = _subprocess.run(base_cmd + compose_down_args,
|
||||||
capture_output=True, text=True, timeout=60)
|
capture_output=True, text=True, timeout=60)
|
||||||
if r.returncode != 0:
|
if r.returncode != 0:
|
||||||
logger.error(f"docker compose down failed: {r.stderr.strip()}")
|
logger.error(f"docker compose down failed: {r.stderr.strip()}")
|
||||||
return
|
return
|
||||||
result = subprocess.run(base_cmd + compose_up_args,
|
result = _subprocess.run(base_cmd + compose_up_args,
|
||||||
capture_output=True, text=True, timeout=120)
|
capture_output=True, text=True, timeout=120)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logger.error(f"docker compose up failed: {result.stderr.strip()}")
|
logger.error(f"docker compose up failed: {result.stderr.strip()}")
|
||||||
|
|||||||
Reference in New Issue
Block a user