test(integration): recognize the model list's lock in the held write helper (#50974)

The registry lock fix (#50933) makes add_deployment and set_model_list wait
for a held delete on the same lock, taken inside HostedModelList as
self._lock. The helper only knew lines spelled with
self._deployment_index_lock, so it never saw those two writes reach the lock
and timed out after 10 seconds.
This commit is contained in:
yuneng-jiang 2026-11-10 10:52:27 -08:00 • committed by GitHub
parent 2624f7caea
commit 906578df39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,15 +39,16 @@ def _router_source_files() -> frozenset[str]:
return frozenset({_HAND_CHANGES.co_filename, *(path for path in facade_files if path is not None)})
def _lock_lines(path: str) -> frozenset[int]:
return frozenset(
number
for number, line in enumerate(linecache.getlines(path), start=1)
if "with self._deployment_index_lock" in line
)
def _lock_lines(path: str, statement: str) -> frozenset[int]:
return frozenset(number for number, line in enumerate(linecache.getlines(path), start=1) if statement in line)
_INDEX_LOCK_LINES: Final = MappingProxyType({path: _lock_lines(path) for path in _router_source_files()})
_INDEX_LOCK_LINES: Final = MappingProxyType(
{
**{path: _lock_lines(path, "with self._deployment_index_lock") for path in _router_source_files()},
_LIST_REFRESH.co_filename: _lock_lines(_LIST_REFRESH.co_filename, "with self._lock"),
}
)
T = TypeVar("T")