MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / drain

Function drain

tests/test_coverage_flush.py:55–78  ·  view source on GitHub ↗
(pipe, destination, state, stop)

Source from the content-addressed store, hash-verified

53
54
55def drain(pipe, destination, state, stop):
56 try:
57 with destination.open("xb", buffering=0) as log:
58 while True:
59 data = pipe.read(4096)
60 if not data:
61 break
62 state["seen_bytes"] += len(data)
63 remaining = LOG_BYTES - state["saved_bytes"]
64 prefix = memoryview(data)[:max(remaining, 0)]
65 while prefix:
66 count = log.write(prefix)
67 if not count:
68 raise OSError("short log write")
69 state["saved_bytes"] += count
70 prefix = prefix[count:]
71 if state["seen_bytes"] > LOG_BYTES:
72 state["overflow"] = True
73 stop.set()
74 except (OSError, ValueError) as exc:
75 state["error"] = str(exc)
76 stop.set()
77 finally:
78 pipe.close()
79
80
81def reap(proc):

Callers

nothing calls this directly

Calls 5

strFunction · 0.85
openMethod · 0.80
readMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected