Repository navigation
BUG: Archive files open for writing in the Windows cache archive - #321
Conversation
hjmjohnson
left a comment
There was a problem hiding this comment.
To answer the question you raised: I'd rather not accept exit code 1. -ssw fixes the incident you hit, and exit 1 can stand for several worse failures than a skipped log.
7-Zip documents exit code 1 as "Warning (Non fatal error(s)) ... one or more files were locked by some other application, so they were not compressed". Without -sse, it also skips input files it cannot open. So exit 1 covers all of these:
- a file another process holds open for writing (your
run2.log): harmless; - a
.lib,.pyd, or header underbuild/that an indexer, antivirus scan, or leftover compiler process holds: the module build fails much later, far from the cause; - access denied on a directory: the whole subtree is missing;
- a file deleted between 7-Zip's scan and its read;
- a missing archive root (
ITK/,build/, or the IPP checkout): 7-Zip warns that it cannot find the file, and the archive is missing that whole root.
With this change, every one of these publishes an incomplete cache and step 07 still reports "completed". The old fallback had the right content. It read run2.log because Python's open() on Windows shares write access and 7-Zip by default does not. The fallback's only cost was a bigger zip.
Why a file was open at all: the build finishes compiling before step 07, and none of the scripts write a log into the archived folders. Your run2.log was the output of this same build, redirected into the checkout, which is one of the archive roots. So the archive step was reading its own log while it was still being written. A log doesn't belong in the build cache in any case, so I'd also add "*.log" to ARCHIVE_EXCLUDES (scripts/windows_build_python_instance.py:18), or note in the docs that redirected output should go outside the checkout. Other ways to hit this (a second build in the same tree, an editor or indexer holding a file) are rare, and they are the cases worth hearing about.
Suggested direction, with details inline:
- Add
-ssw("compresses files open for writing by another applications") and keep== 0. This fixes the case in the PR body. - To find out what a warning was, keep 7-Zip's output: call
run_command(..., stream=True)directly or letecho_check_callreturn theCompletedProcess, then print theWARNING:lines before falling back._run_streamingalready keeps every line, butecho_check_callthrows them away.
Not run on Windows: the 7-Zip exit codes and -ssw come from the 7-Zip docs, and the file-sharing difference and the missing-root warning are reasoned from the code. A Windows check that would settle it: hold a file open with $f=[IO.File]::Open('C:\\P\\IPP\\x.log','Append','Write','Read'), then run 7z a with and without -ssw.
Also, the PR body says pre-commit passes "except prettier"; AGENTS.md asks that pre-commit run --all-files pass on the pushed tip.
5ac0eae to
906b441
Compare
|
Thanks. All points are addressed in 906b441, and |
When the release-wheels output was redirected to a log inside the ITKPythonPackage checkout, 7-Zip could not read that open file, warned, and exited 1. build_tarball then replaced the 7z archive with the slower Python zip fallback. Pass -ssw so 7-Zip also reads files another process holds open for writing. Any other warning can mean a file is missing from the archive, such as an unreadable file or directory, so exit code 1 still goes to the zip fallback. Logs are excluded from the cache, where they do not belong.
906b441 to
a189805
Compare
|
The second force push is a plain rebase. |
Summary
Pass
-sswto 7-Zip so the Windows cache archive includes files another process holds open for writing. Until now, such a file made 7-Zip exit 1, andbuild_tarballreplaced the 7z archive with the zip fallback. Any other 7-Zip warning still goes to the fallback, and logs are no longer cached.How it showed up
The
release-wheelsoutput was redirected torun2.loginside the ITKPythonPackage checkout, which is one of the archived folders. 7-Zip could not read that open file. It wrote the rest of the archive, warned, and exited 1. The build then wrote the Python zip fallback over it.Checked on Windows with a file held open by
[IO.File]::Open(path, 'Append', 'Write', 'Read'): without-ssw, 7-Zip skips it and exits 1; with-ssw, it archives it and exits 0.Type of Change
Checklist
pre-commit run --all-files)docs/)BUG:,COMP:,DOC:,ENH:,PERF:,STYLE:)Platform(s) Tested
AI assistance
🤖 Generated with Claude Code