test(router): hold the concurrent upsert where its build reads the list back (#51878)

Co-authored-by: mateo <277851410+mateo-berri@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
devin-ai-integration[bot] 2026-11-14 23:57:30 +00:00 • committed by GitHub
parent a1ea22e996
commit 4e97503afa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,6 +32,12 @@ _CHURN_UPSERTS: Final = 120
_UNREPORTED_MODEL_ID: Final = frozenset({"aresponses-stream", "aanthropic-messages"})
_LIST_REFRESH: Final = HostedModelList.refresh.__code__
_HAND_CHANGES: Final = HostRegistry._hand_changes.__code__
_REREADS_AFTER_A_WRITE: Final = frozenset(
{
(_LIST_REFRESH, _HAND_CHANGES),
(HostedModelList.end_build.__code__, HostRegistry._run_build.__code__),
}
)
def _router_source_files() -> frozenset[str]:
@ -104,9 +110,7 @@ def _read_during_held_write(read: Callable[[], T], write: Callable[[], object])
def hold_at_reindex(frame: FrameType, event: str, _arg: object) -> None:
caller: Final = frame.f_back
refreshes_after_a_write: Final = (
frame.f_code is _LIST_REFRESH and caller is not None and caller.f_code is _HAND_CHANGES
)
refreshes_after_a_write: Final = caller is not None and (frame.f_code, caller.f_code) in _REREADS_AFTER_A_WRITE
if event == "call" and refreshes_after_a_write and not held.is_set():
held.set()
released_in_time.append(release.wait(timeout=_SYNC_SECONDS))