INNER CODE UNIT · Python
_retrying
feder-cr/Jobs_Applier_AI_Agent_AIHawk · src/aihawk/mcp/server.py:142
async def _retrying(fn, *args, **kwargs):
"""Run an action, and on failure rebuild the session once and retry.
A browser that died between two calls is the ordinary case here, not an
exotic one: the object is still intact, so the failure surfaces inside the
action rather than when the session was handed out.
"""
session = await registry.ensure()
try:
return await fn(session, *args, **kwargs)
except Exception:
await registry.drop()
session = await registry.ensure()
return await fn(session, *args, **kwargs)
# --- who is browsing -------------------------------------------------------