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

Fix OSError: [Errno 26] Text file busy:... #55

Merged
merged 2 commits into from Sep 22, 2022
Merged

Fix OSError: [Errno 26] Text file busy:... #55

merged 2 commits into from Sep 22, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jul 8, 2020

Sometimes Python raises OSError: [Errno 26] Text file busy, to prevent this error, the force_remove function has been added.

Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, this could be a better approach:

def force_remove(file_id):
    while True:
        try:
            os.remove(file_id)
            break
        except:
            print('Cannot remove {}, because it is busy, trying again...'.format(file_id))
            time.sleep(1)

This piece of code is better technically, but the last implementation, is more readable.

@matthdsm matthdsm merged commit dc53a99 into CenterForMedicalGeneticsGhent:master Sep 22, 2022
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 this pull request may close these issues.

2 participants