diff options
author | Stanisław Skonieczny <stanislaw.skonieczny@gmail.com> | 2021-09-07 17:55:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-07 17:55:20 (GMT) |
commit | 9dc363ee7cf2eb6ff374fbf7bbeb0b333f4afb8f (patch) | |
tree | 53bbca979f651c59c3dbe080b185db5fa846b82c /Modules | |
parent | 750368cbcd20393026f3bf695195f1a2cba490b5 (diff) | |
download | cpython-9dc363ee7cf2eb6ff374fbf7bbeb0b333f4afb8f.zip cpython-9dc363ee7cf2eb6ff374fbf7bbeb0b333f4afb8f.tar.gz cpython-9dc363ee7cf2eb6ff374fbf7bbeb0b333f4afb8f.tar.bz2 |
bpo-45012: Release GIL around stat in os.scandir (GH-28085)
Releasing GIL allows other threads to continue
its work when os.scandir is fetching DirEntry.stat
info from file system.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 73e7e60..89659ae 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -13489,8 +13489,10 @@ _Py_COMP_DIAG_POP if (self->dir_fd != DEFAULT_DIR_FD) { #ifdef HAVE_FSTATAT if (HAVE_FSTATAT_RUNTIME) { + Py_BEGIN_ALLOW_THREADS result = fstatat(self->dir_fd, path, &st, follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW); + Py_END_ALLOW_THREADS } else #endif /* HAVE_FSTATAT */ @@ -13503,10 +13505,14 @@ _Py_COMP_DIAG_POP else #endif { - if (follow_symlinks) + Py_BEGIN_ALLOW_THREADS + if (follow_symlinks) { result = STAT(path, &st); - else + } + else { result = LSTAT(path, &st); + } + Py_END_ALLOW_THREADS } #if defined(MS_WINDOWS) && !USE_UNICODE_WCHAR_CACHE PyMem_Free(path); |