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

github actions recursion error #1252

Closed
maxbachmann opened this issue Sep 3, 2022 · 3 comments · Fixed by #1253
Closed

github actions recursion error #1252

maxbachmann opened this issue Sep 3, 2022 · 3 comments · Fixed by #1253

Comments

@maxbachmann
Copy link
Contributor

Description

In one of my builds there is a permission error when cibuildwheel attempts to delete one of it's temporary files: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\cibw-sdist-aysdq8e6' which appears to be used by another process. This leads to a recursion error when cibuildwheel attempts to delete the file repeatedly:

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\shutil.py", line 621, in _rmtree_unsafe
    os.rmdir(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\cibw-sdist-aysdq8e6'
   File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\tempfile.py", line 855, in _rmtree
    _shutil.rmtree(name, onerror=onerror)
  File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\shutil.py", line 749, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\shutil.py", line 623, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\tempfile.py", line 840, in onerror
    resetperms(path)
  File "C:\hostedtoolcache\windows\Python\3.10.6\x64\lib\tempfile.py", line 832, in resetperms
    _os.chflags(path, 0)
RecursionError: maximum recursion depth exceeded while calling a Python object

Build log

https://github.com/maxbachmann/JaroWinkler/runs/8168022602?check_suite_focus=true

CI config

https://github.com/maxbachmann/JaroWinkler/blob/build_sdist/.github/workflows/releasebuild.yml

@maxbachmann
Copy link
Contributor Author

Restarting the build fixed the issue.
Looking into it this appears to be an issue inside cpython:

https://github.com/python/cpython/blob/3.11/Lib/tempfile.py#L877-L881

can lead to indefinite recursion

@maxbachmann
Copy link
Contributor Author

This should be the following issue in CPython python/cpython#86962 and is caused by the temp directory creation here:

with tempfile.TemporaryDirectory(prefix="cibw-sdist-") as temp_dir_str:

Maybe we can just catch this RecursionError and ignore it if it occurs similar to the onerror=True that is used on Windows when calling rmtree.

@joerick
Copy link
Contributor

joerick commented Sep 3, 2022

Hmm. Thanks for the report. Yes that looks to be the issue. The only thing I don't understand is why the rmtree fails in the tempfile case, since while we do chdir to that temp directory, the context manager does chdir back to the original working dir before the tempdir is deleted.

Either way, I agree that it's not good to fail the whole build because cleanup failed - logging a warning is sufficient.

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

Successfully merging a pull request may close this issue.

2 participants