Skip to content

Fix flaky Windows write-lock: retry on PermissionError#36

Merged
gowtham0992 merged 1 commit into
mainfrom
fix-windows-file-lock
Jun 24, 2026
Merged

Fix flaky Windows write-lock: retry on PermissionError#36
gowtham0992 merged 1 commit into
mainfrom
fix-windows-file-lock

Conversation

@gowtham0992

Copy link
Copy Markdown
Owner

_file_lock only treated FileExistsError as a contended lock. On Windows, os.open(O_CREAT|O_EXCL) raises PermissionError when the lock file already exists or is being unlinked by another holder, so under concurrent writes the lock would propagate that error instead of retrying — making test_files_core flaky on Windows CI.

Catch PermissionError alongside FileExistsError in the acquire loop (the standard portable file-lock pattern) and add a regression test that forces a transient PermissionError on the exclusive open.

_file_lock only treated FileExistsError as a contended lock. On Windows,
os.open(O_CREAT|O_EXCL) raises PermissionError when the lock file already
exists or is being unlinked by another holder, so under concurrent writes
the lock would propagate that error instead of retrying — making
test_files_core flaky on Windows CI.

Catch PermissionError alongside FileExistsError in the acquire loop (the
standard portable file-lock pattern) and add a regression test that
forces a transient PermissionError on the exclusive open.
@gowtham0992 gowtham0992 merged commit 8c69970 into main Jun 24, 2026
8 checks passed
@gowtham0992 gowtham0992 deleted the fix-windows-file-lock branch June 24, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant