diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-04 17:27:10 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-04 17:27:10 (GMT) |
commit | 247e2fd035c0b8becfec3609330405195adf4bb2 (patch) | |
tree | d959c93d9ee8db24f44c2aeb47531e37845fe7f2 | |
parent | 6807958dd4efc4caa7bd2a10f0d7fc95f1441f00 (diff) | |
download | cpython-247e2fd035c0b8becfec3609330405195adf4bb2.zip cpython-247e2fd035c0b8becfec3609330405195adf4bb2.tar.gz cpython-247e2fd035c0b8becfec3609330405195adf4bb2.tar.bz2 |
Merged revisions 84489 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r84489 | antoine.pitrou | 2010-09-04 19:21:57 +0200 (sam., 04 sept. 2010) | 4 lines
Issue #7736: Release the GIL around calls to opendir() and closedir()
in the posix module. Patch by Marcin Bachry.
........
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/posixmodule.c | 11 |
2 files changed, 13 insertions, 1 deletions
@@ -225,6 +225,9 @@ Library Extension Modules ----------------- +- Issue #7736: Release the GIL around calls to opendir() and closedir() + in the posix module. Patch by Marcin Bachry. + - As a result of issue #2521, the _weakref module is now compiled into the interpreter by default. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 5237f14..933dbd9 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2333,11 +2333,16 @@ posix_listdir(PyObject *self, PyObject *args) } if (!PyArg_ParseTuple(args, "et:listdir", Py_FileSystemDefaultEncoding, &name)) return NULL; - if ((dirp = opendir(name)) == NULL) { + Py_BEGIN_ALLOW_THREADS + dirp = opendir(name); + Py_END_ALLOW_THREADS + if (dirp == NULL) { return posix_error_with_allocated_filename(name); } if ((d = PyList_New(0)) == NULL) { + Py_BEGIN_ALLOW_THREADS closedir(dirp); + Py_END_ALLOW_THREADS PyMem_Free(name); return NULL; } @@ -2350,7 +2355,9 @@ posix_listdir(PyObject *self, PyObject *args) if (errno == 0) { break; } else { + Py_BEGIN_ALLOW_THREADS closedir(dirp); + Py_END_ALLOW_THREADS Py_DECREF(d); return posix_error_with_allocated_filename(name); } @@ -2391,7 +2398,9 @@ posix_listdir(PyObject *self, PyObject *args) } Py_DECREF(v); } + Py_BEGIN_ALLOW_THREADS closedir(dirp); + Py_END_ALLOW_THREADS PyMem_Free(name); return d; |