-
Notifications
You must be signed in to change notification settings - Fork 66
fix: fix file locking error when removing cache folder #162
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| import os | ||
| import shutil | ||
| import time | ||
| import uuid | ||
| import shutil | ||
| import os | ||
| import sys | ||
| import stat | ||
|
|
||
|
|
||
| def setup_workspace(folder): | ||
|
|
@@ -17,6 +20,18 @@ def setup_workspace(folder): | |
| return log_file, working_dir | ||
|
|
||
|
|
||
| def cleanup_workspace(folder): | ||
| if os.path.exists(folder): | ||
| shutil.rmtree(folder) | ||
| def on_rm_error(func, path, exc_info): | ||
| st = os.stat(path) | ||
| os.chmod(path, st.st_mode | stat.S_IWRITE) | ||
|
|
||
| time.sleep(0.5) | ||
| try: | ||
| func(path) | ||
| except Exception: | ||
github-code-quality[bot] marked this conversation as resolved.
Fixed
Show fixed
Hide fixed
github-code-quality[bot] marked this conversation as resolved.
Fixed
Show fixed
Hide fixed
|
||
| pass | ||
|
Comment on lines
+30
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silently swallowing exceptions with |
||
|
|
||
| def cleanup_workspace(working_dir): | ||
| if sys.version_info >= (3, 12): | ||
| shutil.rmtree(working_dir, onexc=on_rm_error) | ||
| else: | ||
| shutil.rmtree(working_dir, onerror=on_rm_error) | ||
Uh oh!
There was an error while loading. Please reload this page.