mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-29 18:46:59 +00:00
refactor(cli): run the web-UI staleness walk once, under the build lock
The flock wrapper checked _web_ui_build_needed twice (pre-lock fast path and post-lock re-check) and _do_build_web_ui checks it again internally, so a boot that actually built walked the whole web/ source tree three times. The callee's own check already runs under the lock on every path through the wrapper, so it alone is sufficient: drop both wrapper checks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
3a9b2f2f84
commit
37396fc66d
1 changed files with 4 additions and 6 deletions
|
|
@ -5160,11 +5160,13 @@ def _build_web_ui(web_dir: Path, *, fatal: bool = False) -> bool:
|
|||
boot re-triggered the build. One process builds under an exclusive
|
||||
flock; the rest serve the existing dist (stale is acceptable) or, when
|
||||
no dist exists yet, block until the builder finishes.
|
||||
|
||||
Staleness is checked once, inside :func:`_do_build_web_ui`, after the
|
||||
lock is held — so a process that queued behind the builder skips the
|
||||
rebuild, and the (os.walk-based) check runs at most once per boot.
|
||||
"""
|
||||
if not (web_dir / "package.json").exists():
|
||||
return True
|
||||
if not _web_ui_build_needed(web_dir):
|
||||
return True
|
||||
try:
|
||||
import fcntl
|
||||
except ImportError:
|
||||
|
|
@ -5186,10 +5188,6 @@ def _build_web_ui(web_dir: Path, *, fatal: bool = False) -> bool:
|
|||
return True
|
||||
# No dist at all (first-ever build): wait for the builder.
|
||||
fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX)
|
||||
# Re-check under the lock: the previous holder may have finished
|
||||
# the build while this process was waiting or racing for it.
|
||||
if not _web_ui_build_needed(web_dir):
|
||||
return True
|
||||
return _do_build_web_ui(web_dir, fatal=fatal)
|
||||
finally:
|
||||
lock_file.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue