NamedTemporaryFile opened in read mode cannot be written to by another process on Windows
|Reported by:||Owned by:||Kevin Christopher Henry|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The documentation for NamedTemporaryFile says that it exists so that on Windows so other processes can open the file, which is not possible using Python's implementation of NamedTemporaryFile because of the O_TEMPORARY flag that is passed by default.
However, if the temporary file is opened in read mode (r+), another process cannot write to the file, unless the temp file is closed before the outside process is called. This comes up with django_compressor when trying to use lessc (either https://github.com/duncansmart/less.js-windows or http://www.dotlesscss.org/).
I've attached a test that demonstrates the problem. On *nix, this test should pass.
Change History (9)
comment:4 Changed 3 years ago by
|Component:||Core (Other) → File uploads/storage|
|Owner:||changed from nobody to Kevin Christopher Henry|
|Status:||new → assigned|
|Type:||Bug → Cleanup/optimization|
|Version:||1.4 → master|