Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.rename() and os.remove() don't work in Windows #7

Open
whitlockjc opened this issue Nov 15, 2015 · 2 comments
Open

os.rename() and os.remove() don't work in Windows #7

whitlockjc opened this issue Nov 15, 2015 · 2 comments

Comments

@whitlockjc
Copy link
Owner

print_group_model throws unhandled exceptions under Windows because the OS thinks that the temp file is open at the time you're trying to rename or delete it.

@whitlockjc
Copy link
Owner Author

More details from previous issue.

Yeah, we've had the same issue. os.remove(tmp_authz_path) cannot remove the file due to it being used by another process, or as I suspect, the same process. This script isn't able to close the file before it's supposed to be removed. We put in a time.sleep(5) before os.remove but no improvement.

We are running windows 2008 32bit.

@sirfene
Copy link

sirfene commented Jan 20, 2017

We experienced the same problem. I fixed it by adding os.close(tmp_fd) before os.remove(tmp_authz_path)
In the end it looks like this:

...
tmpfile.close()
os.close(tmp_fd)
os.remove(tmp_authz_path)
...

Hope this helps.
Stefan

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

No branches or pull requests

2 participants