claude-proxy / tests /runtime /catalog_support.py
dheraingoud's picture
Copilot App
Sync upstream v6.19.35 and preserve custom addons
a9e27c0
Raw History Blame Contribute Delete
1.1 kB
"""Wait for owned work in tests without imposing it on catalog consumers."""
import asyncio
from contextlib import asynccontextmanager
from free_claude_code.core.async_rwlock import AsyncReadWriteLock
from free_claude_code.runtime.provider_manager import ProviderRuntimeManager
async def finish_discovery(manager: ProviderRuntimeManager) -> None:
await manager._start_pass(manager._current)
async def finish_publication(manager: ProviderRuntimeManager) -> None:
task = manager._publication_task
if task is not None:
await task
def pause_next_write(monkeypatch, lock: AsyncReadWriteLock):
"""Pause one operation before ownership, allowing a later action to overtake it."""
entered, release = asyncio.Event(), asyncio.Event()
original = lock.write
first = True
@asynccontextmanager
async def held():
nonlocal first
if first:
first = False
entered.set()
await release.wait()
async with original():
yield
monkeypatch.setattr(lock, "write", held)
return entered, release