mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 21:44:18 +02:00
fix: Client OAuth async_auth_flow() method causing MCP-SDK self.context.lock error. (#2644)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
This commit is contained in:
parent
568300e8b5
commit
650b103dbf
1 changed files with 19 additions and 13 deletions
|
|
@ -298,13 +298,16 @@ class OAuth(OAuthClientProvider):
|
|||
# First attempt with potentially cached credentials
|
||||
gen = super().async_auth_flow(request)
|
||||
response = None
|
||||
while True:
|
||||
try:
|
||||
# First iteration sends None, subsequent iterations send response
|
||||
yielded_request = await gen.asend(response) # ty: ignore[invalid-argument-type]
|
||||
response = yield yielded_request
|
||||
except StopAsyncIteration:
|
||||
break
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
# First iteration sends None, subsequent iterations send response
|
||||
yielded_request = await gen.asend(response) # ty: ignore[invalid-argument-type]
|
||||
response = yield yielded_request
|
||||
except StopAsyncIteration:
|
||||
break
|
||||
finally:
|
||||
await gen.aclose()
|
||||
|
||||
except ClientNotFoundError:
|
||||
logger.debug(
|
||||
|
|
@ -317,9 +320,12 @@ class OAuth(OAuthClientProvider):
|
|||
# Retry with fresh registration
|
||||
gen = super().async_auth_flow(request)
|
||||
response = None
|
||||
while True:
|
||||
try:
|
||||
yielded_request = await gen.asend(response) # ty: ignore[invalid-argument-type]
|
||||
response = yield yielded_request
|
||||
except StopAsyncIteration:
|
||||
break
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
yielded_request = await gen.asend(response) # ty: ignore[invalid-argument-type]
|
||||
response = yield yielded_request
|
||||
except StopAsyncIteration:
|
||||
break
|
||||
finally:
|
||||
await gen.aclose()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue