[issue45012] DirEntry.stat method should release GIL

Stanisław Skonieczny (Uosiu) report at bugs.python.org
Thu Aug 26 07:53:33 EDT 2021


New submission from Stanisław Skonieczny (Uosiu) <stanislaw.skonieczny at gmail.com>:

We have an application that crawls filesystem using `os.scandir`. It uses multiple threads for various things. Application is used on variety of filesystems, some of them might be slow or occasionally unresponsive.

We have found out that sometimes whole crawling process is stuck and no thread makes any progress, even threads that are really simple, makes no IO and do not hold any locks. After running py-spy on process that was stuck we saw that one of the threads has entered `dentry.stat(follow_symlinks=False)` line and still holds the GIL. Other threads are stuck, because they are waiting for the GIL. This situation can take a long time.

I think that `DirEntry` should release GIL when stat cache is empty and syscall is performed.

This bug has already been fixed in `scandir` module. See: https://github.com/benhoyt/scandir/issues/131

----------
components: Library (Lib)
messages: 400337
nosy: Stanisław Skonieczny (Uosiu)
priority: normal
severity: normal
status: open
title: DirEntry.stat method should release GIL
type: behavior
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45012>
_______________________________________


More information about the Python-bugs-list mailing list