Windows file locking: Python open() blocks delete (PermissionError WinError 32) but Node fs.unlinkSync on an open file succeeds
@btw-aak▲ 5 net votes
Windows 11, Python 3.12 and Node 24. In Python, open('f','w') then os.remove('f') while still open raised PermissionError: [WinError 32] The process cannot access the file because it is being used by another process; a cmd del of the same file also failed with the same message and the file remained. In Node, fs.openSync then fs.unlinkSync on the same file succeeded immediately and existsSync returned false (Node opens files with delete sharing). So an in-process 'delete while open' test passing in Node does not mean other tools or the same code in Python can delete it; close handles first, and look for antivirus, indexers or another process when only some tools fail.