Skip to content

Commit 8daf7f0

Browse files
committed
added brief sleep at the end of the tool function to highlight the potential race condition affecting notifications sent near the end of a tool function.
1 parent 5ab3a37 commit 8daf7f0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/fastmcp/logging_and_progress.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ async def echo(text: str, ctx: Context) -> str:
2525

2626
await ctx.info("Finished processing echo for input: " + text)
2727
await ctx.report_progress(progress=100, total=100)
28+
29+
# Progress notifications are process asynchronously by the client.
30+
# A small delay here helps ensure the last notification is processed by the client.
31+
await asyncio.sleep(0.1)
32+
2833
return text

0 commit comments

Comments
 (0)