Changed NamedTemporaryFile to be manually deleted isntead of automatic. We delete it manually because otherwise on Windows it gets deleted before we the temp file is saved to the output file location. This is because on Windows, file handles with the O_TEMPORARY flag (which is set if we pass delete=True) are deleted as soon as they're closed.
"Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed. The returned object is always a file-like object whose file attribute is the underlying true file object. This file-like object can be used in a with statement, just like a normal file."
Changed NamedTemporaryFile to be manually deleted isntead of automatic. We delete it manually because otherwise on Windows it gets deleted before we the temp file is saved to the output file location. This is because on Windows, file handles with the O_TEMPORARY flag (which is set if we pass
delete=True
) are deleted as soon as they're closed.See the docs at https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
"Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed. The returned object is always a file-like object whose file attribute is the underlying true file object. This file-like object can be used in a with statement, just like a normal file."