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

Race condition: collection error when directory is deleted before scandir() runs #13083

Open
Zac-HD opened this issue Dec 24, 2024 · 0 comments · May be fixed by #13084 or #13086
Open

Race condition: collection error when directory is deleted before scandir() runs #13083

Zac-HD opened this issue Dec 24, 2024 · 0 comments · May be fixed by #13084 or #13086
Labels
good first issue easy issue that is friendly to new contributor type: bug problem that needs to be addressed

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Dec 24, 2024

Our scandir() function crashes if the directory to scan does not exist, which can happen if e.g. a tempory directory is deleted during collection (as in HypothesisWorks/hypothesis#4200). I therefore propose catching the directory-not-found error and returning [] in this case:

try:
    with os.scandir(path) as s:
        scanned = list(s)
except FileNotFoundError:
    return []
# Skip entries with symlink loops and other brokenness, so the caller
# doesn't have to deal with it.
for entry in scanned:
    ...
@Zac-HD Zac-HD added type: bug problem that needs to be addressed good first issue easy issue that is friendly to new contributor labels Dec 24, 2024
@aday2418 aday2418 linked a pull request Dec 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor type: bug problem that needs to be addressed
Projects
None yet
1 participant