Await endpoint.session() in null pyworker client
endpoint.session() forwards to start_endpoint_session, which is async def — so the call returns a coroutine, not a Session, despite the SDK's return-type annotation. Use 'async with await endpoint.session(...)' so the coroutine resolves to a Session before entering the context. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,7 @@ async def reserve(
|
|||||||
lifetime = hold_for + 60
|
lifetime = hold_for + 60
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
log.info("[%s] creating session (lifetime=%.0fs, hold=%.0fs)", label, lifetime, hold_for)
|
log.info("[%s] creating session (lifetime=%.0fs, hold=%.0fs)", label, lifetime, hold_for)
|
||||||
async with endpoint.session(cost=SESSION_COST, lifetime=lifetime) as s:
|
async with await endpoint.session(cost=SESSION_COST, lifetime=lifetime) as s:
|
||||||
log.info("[%s] session %s open", label, s.session_id)
|
log.info("[%s] session %s open", label, s.session_id)
|
||||||
try:
|
try:
|
||||||
await asyncio.sleep(hold_for)
|
await asyncio.sleep(hold_for)
|
||||||
|
|||||||
Reference in New Issue
Block a user