sync-ldap-groups-to-svn-authz icon indicating copy to clipboard operation
sync-ldap-groups-to-svn-authz copied to clipboard

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

Open whitlockjc opened this issue 9 years ago • 2 comments

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 avatar Nov 15 '15 03:11 whitlockjc

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.

whitlockjc avatar Nov 15 '15 03:11 whitlockjc

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

sirfene avatar Jan 20 '17 09:01 sirfene