Skip to content

fix: close temp file before trying to move/delete#449

Merged
danielolsen merged 1 commit intodevelopfrom
daniel/tempfile_cleanup
Apr 13, 2021
Merged

fix: close temp file before trying to move/delete#449
danielolsen merged 1 commit intodevelopfrom
daniel/tempfile_cleanup

Conversation

@danielolsen
Copy link
Copy Markdown
Contributor

@danielolsen danielolsen commented Apr 13, 2021

Purpose

Fix the PermissionsErrors we had been getting on Windows.

What the code is doing

After writing to the tempfile, we tell the os to close the file before we try to do anything with it (e.g. move, delete). I got this from this stackoverflow post: https://stackoverflow.com/questions/34716996/cant-remove-a-file-which-created-by-tempfile-mkstemp-on-windows

Testing

Tests on Windows now pass, and I've successfully tested that this can create/prepare/launch a scenario on the server (previously had been failing so I fell back to the 'v0.4.1' branch).

Previously all test_execute_csv and test_scenario_csv tests failed with an error like:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\DanielOlsen\\ScenarioData\\tmpmvu_jnyl'

Time estimate

5-15 minutes, depending on how far you want to go down the low level file API rabbit hole.

@danielolsen danielolsen added the bug Something isn't working label Apr 13, 2021
@danielolsen danielolsen requested review from jenhagg and rouille April 13, 2021 03:27
Copy link
Copy Markdown
Collaborator

@rouille rouille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything wrong with that

Copy link
Copy Markdown
Collaborator

@BainanXia BainanXia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense.

@danielolsen danielolsen merged commit 53aea2a into develop Apr 13, 2021
@danielolsen danielolsen deleted the daniel/tempfile_cleanup branch April 13, 2021 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants