mapillary / mapillary_tools

Command line tools for processing and uploading Mapillary imagery
BSD 2-Clause "Simplified" License
256 stars 134 forks source link

wip_dir Context Manager Rename Retry #639

Closed TManzini closed 1 year ago

TManzini commented 1 year ago

This fix will attempt to rename the temporary folder for 10sec. This is due to an issue on windows machines that causes the renaming of the temporary folder to result in a PermissionError for several seconds after the last image is written.

facebook-github-bot commented 1 year ago

Hi @TManzini!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

ptpt commented 1 year ago

Thanks for the PR @TManzini

Could you provide more context on the permission issue (e.g. any links)?

TManzini commented 1 year ago

Sure, unfortunately the details around this behavior are poorly documented, but here is the trail that I followed to arrive at the PR.

When running the process_video script I kept getting PermissionError: [WinError 5] Access is denied: <PATH_TO_WIP_DIR> -> <PATH_TO_DONE_DIR>

So the suggestion is to continuously retry the rename for a certain amount of time until the OS realizes the rename is okay, or it times out. I set 10s as an arbitrary number. This behavior only seems to occur on windows.

ptpt commented 1 year ago

Thanks for the context! Lets narrow the hack to the windows platform only.

ptpt commented 1 year ago

@TManzini If you could sign the CLA above, I'm happy to merge the PR to a branch and I will fix some minor issues there.

TManzini commented 1 year ago

Let me know if you are happy with this implementation