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

Function publish_barrier_file

scripts/run-test-wave.py:153–175  ·  view source on GitHub ↗

Publish a barrier file so a poller sees either no file or its content. Path.write_text creates and truncates before it writes, so a reader that polls for existence and then parses the content can observe the zero-byte window in between. Write next to the destination and rename into pla

(path: pathlib.Path, text: str)

Source from the content-addressed store, hash-verified

151
152
153def publish_barrier_file(path: pathlib.Path, text: str) -> None:
154 """Publish a barrier file so a poller sees either no file or its content.
155
156 Path.write_text creates and truncates before it writes, so a reader that
157 polls for existence and then parses the content can observe the zero-byte
158 window in between. Write next to the destination and rename into place.
159 """
160 with tempfile.NamedTemporaryFile(
161 mode="w",
162 encoding="utf-8",
163 newline="\n",
164 dir=path.parent,
165 prefix=f".{path.name}.",
166 delete=False,
167 ) as temporary:
168 temporary.write(text)
169 temporary.flush()
170 temporary_path = pathlib.Path(temporary.name)
171 try:
172 os.replace(temporary_path, path)
173 except BaseException:
174 temporary_path.unlink(missing_ok=True)
175 raise
176
177
178def start_suite(

Calls 2

flushMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected