[Python-checkins] r84489 - in python/branches/py3k: Misc/NEWS Modules/posixmodule.c

antoine.pitrou python-checkins at python.org
Sat Sep 4 19:21:57 CEST 2010


Author: antoine.pitrou
Date: Sat Sep  4 19:21:57 2010
New Revision: 84489

Log:
Issue #7736: Release the GIL around calls to opendir() and closedir()
in the posix module.  Patch by Marcin Bachry.



Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/posixmodule.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Sep  4 19:21:57 2010
@@ -93,6 +93,9 @@
 Extensions
 ----------
 
+- Issue #7736: Release the GIL around calls to opendir() and closedir()
+  in the posix module.  Patch by Marcin Bachry.
+
 - Issue #4835: make PyLong_FromSocket_t() and PyLong_AsSocket_t() private
   to the socket module, and fix the width of socket descriptors to be
   correctly detected under 64-bit Windows.

Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c	(original)
+++ python/branches/py3k/Modules/posixmodule.c	Sat Sep  4 19:21:57 2010
@@ -2580,11 +2580,16 @@
       oname = PyBytes_FromString(".");
     }
     name = PyBytes_AsString(oname);
-    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(oname);
     }
     if ((d = PyList_New(0)) == NULL) {
+        Py_BEGIN_ALLOW_THREADS
         closedir(dirp);
+        Py_END_ALLOW_THREADS
         Py_DECREF(oname);
         return NULL;
     }
@@ -2597,7 +2602,9 @@
             if (errno == 0) {
                 break;
             } else {
+                Py_BEGIN_ALLOW_THREADS
                 closedir(dirp);
+                Py_END_ALLOW_THREADS
                 Py_DECREF(d);
                 return posix_error_with_allocated_filename(oname);
             }
@@ -2621,7 +2628,9 @@
         }
         Py_DECREF(v);
     }
+    Py_BEGIN_ALLOW_THREADS
     closedir(dirp);
+    Py_END_ALLOW_THREADS
     Py_DECREF(oname);
 
     return d;


More information about the Python-checkins mailing list