mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix(cron): use delta-based env restore instead of clear+update
Avoids a brief window where other threads see an empty os.environ during profile job teardown. Idea from PR #19958.
This commit is contained in:
parent
1f9b2e4d0b
commit
1d74d7f73a
1 changed files with 8 additions and 2 deletions
|
|
@ -192,8 +192,14 @@ def _job_profile_context(job_id: str, profile: Optional[str]):
|
|||
_hermes_home = prior_override
|
||||
if override_token is not None:
|
||||
reset_hermes_home_override(override_token)
|
||||
os.environ.clear()
|
||||
os.environ.update(env_snapshot)
|
||||
# Delta-based restore: remove added keys, restore changed keys.
|
||||
# Avoids a brief window where other threads see an empty env.
|
||||
added = set(os.environ.keys()) - set(env_snapshot.keys())
|
||||
for k in added:
|
||||
os.environ.pop(k, None)
|
||||
for k, v in env_snapshot.items():
|
||||
if os.environ.get(k) != v:
|
||||
os.environ[k] = v
|
||||
|
||||
|
||||
def _resolve_origin(job: dict) -> Optional[dict]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue