MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / hook

Function hook

tests/lib/tools/memory_sync/test_final_flush.py:105–118  ·  view source on GitHub ↗
(_path: str)

Source from the content-addressed store, hash-verified

103 release = anyio.Event()
104
105 async def hook(_path: str) -> None:
106 nonlocal in_flight, peak
107 in_flight += 1
108 peak = max(peak, in_flight)
109 try:
110 if in_flight == 2 and not release.is_set():
111 # Hold both a little longer so a flush that ignored the bound
112 # would have time to start a third upload before they leave.
113 await anyio.sleep(0.1)
114 release.set()
115 with anyio.fail_after(5):
116 await release.wait()
117 finally:
118 in_flight -= 1
119
120 server.upload_hook = hook
121 await stores.flush_writes()

Callers

nothing calls this directly

Calls 4

sleepMethod · 0.80
setMethod · 0.45
waitMethod · 0.45
cancelMethod · 0.45

Tested by

no test coverage detected