MCPcopy
hub / github.com/aio-libs/aiohttp / auto_refresh_client

Function auto_refresh_client

docs/code/client_middleware_cookbook.py:107–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105
106 @asynccontextmanager
107 async def auto_refresh_client() -> AsyncIterator[ClientSession]:
108 async with ClientSession() as session:
109 ready = asyncio.Event()
110 t = asyncio.create_task(set_token(session, ready))
111 await ready.wait()
112 yield session
113 t.cancel()
114 with suppress(asyncio.CancelledError):
115 await t
116
117 async with auto_refresh_client() as sess:
118 ...

Callers 1

Calls 2

ClientSessionClass · 0.90
set_tokenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…