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

Method drain

tests/coverage_live_v2_support.py:97–118  ·  view source on GitHub ↗
(source, destination)

Source from the content-addressed store, hash-verified

95 record["pid"] = process.pid
96
97 def drain(source, destination):
98 try:
99 with Path(destination).open("xb") as output:
100 while True:
101 block = source.read(65536)
102 if not block:
103 break
104 with lock:
105 remaining = max(0, min(64 * 1024 * 1024 - state["bytes"],
106 512 * 1024 * 1024 - self.total_output_bytes))
107 state["bytes"] += len(block)
108 self.total_output_bytes += len(block)
109 if len(block) > remaining:
110 state["overflow"] = True
111 stop.set()
112 output.write(block[:remaining])
113 except Exception as exc:
114 with lock:
115 state["errors"].append(str(exc))
116 stop.set()
117 finally:
118 source.close()
119
120 threads = [threading.Thread(target=drain, args=(source, record[name]), daemon=True)
121 for source, name in ((process.stdout, "stdout"), (process.stderr, "stderr"))]

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