fix: replace double-lambda with functools.partial, close from_env config_path gap
- _submit_background and _prefetch_provider: replace unreadable (lambda inner: (lambda: ctx.run(inner)))(fn) with functools.partial(ctx.run, fn) - from_env(): set config_path=resolve_config_path() so bound_config_path() doesn't re-resolve from ContextVar on daemon threads (the exact bug the PR fixes for from_global_config) Review follow-ups for salvaged PR #83525.
This commit is contained in:
parent
3a7d29a8ad
commit
5118692c25
|
|
@ -562,10 +562,10 @@ class MemoryManager:
|
|||
# Propagate the caller's contextvars (profile HERMES_HOME override)
|
||||
# to the prefetch thread — see _submit_background.
|
||||
import contextvars
|
||||
from functools import partial
|
||||
|
||||
_ctx = contextvars.copy_context()
|
||||
thread = threading.Thread(
|
||||
target=lambda: _ctx.run(_run),
|
||||
target=partial(contextvars.copy_context().run, _run),
|
||||
daemon=True,
|
||||
name=f"memory-prefetch-{provider.name}",
|
||||
)
|
||||
|
|
@ -743,9 +743,10 @@ class MemoryManager:
|
|||
from the worker would silently land on the default profile.
|
||||
"""
|
||||
import contextvars
|
||||
from functools import partial
|
||||
|
||||
ctx = contextvars.copy_context()
|
||||
fn = (lambda inner: (lambda: ctx.run(inner)))(fn)
|
||||
fn = partial(ctx.run, fn)
|
||||
executor = self._get_sync_executor()
|
||||
if executor is None:
|
||||
if self._shutting_down:
|
||||
|
|
|
|||
|
|
@ -491,6 +491,7 @@ class HonchoClientConfig:
|
|||
api_key = get_secret("HONCHO_API_KEY")
|
||||
base_url = os.environ.get("HONCHO_BASE_URL", "").strip() or None
|
||||
timeout = _resolve_optional_float(os.environ.get("HONCHO_TIMEOUT"))
|
||||
_resolved_path = resolve_config_path()
|
||||
return cls(
|
||||
host=resolved_host,
|
||||
workspace_id=workspace_id,
|
||||
|
|
@ -500,6 +501,7 @@ class HonchoClientConfig:
|
|||
timeout=timeout,
|
||||
ai_peer=resolved_host,
|
||||
enabled=bool(api_key or base_url),
|
||||
config_path=_resolved_path,
|
||||
hermes_home=get_hermes_home(),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue