]> granicus.if.org Git - python/commitdiff
Issue #6915: Under Windows, os.listdir() didn't release the Global
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 9 Aug 2010 23:39:31 +0000 (23:39 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 9 Aug 2010 23:39:31 +0000 (23:39 +0000)
Interpreter Lock around all system calls.  Original patch by Ryan Kelly.

Misc/ACKS
Misc/NEWS
Modules/posixmodule.c

index 41d314e19642ee2cce9c1949cc4d9c6b2e2a0db6..6f689adce89570b6a56f2fc7f97cbd2973980e52 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -419,6 +419,7 @@ Jacob Kaplan-Moss
 Lou Kates
 Hiroaki Kawai
 Sebastien Keim
+Ryan Kelly
 Robert Kern
 Randall Kern
 Magnus Kessler
index ef35ddcd690e84a7932c7aa6e8780e025cd51121..b89f89d1ce462ed5cd8286e461c5e6153d138c72 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,9 @@ Core and Builtins
 Extensions
 ----------
 
+- Issue #6915: Under Windows, os.listdir() didn't release the Global
+  Interpreter Lock around all system calls.  Original patch by Ryan Kelly.
+
 - Issue #8524: Add a detach() method to socket objects, so as to put the
   socket into the closed state without closing the underlying file
   descriptor.
index 0b14f5cc22b3e7111bf085c466a98235ed10acd9..449093a7fc859bdfa1d58783cf4cba631989a003 100644 (file)
@@ -1229,7 +1229,7 @@ win32_stat_w(const wchar_t* path, struct win32_stat *result)
         /* FILE_FLAG_BACKUP_SEMANTICS is required to open a directory */
         FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS,
         NULL);
-    
+
     if(hFile == INVALID_HANDLE_VALUE) {
         /* Either the target doesn't exist, or we don't have access to
            get a handle to it. If the former, we need to return an error.
@@ -2353,7 +2353,9 @@ posix_listdir(PyObject *self, PyObject *args)
             free(wnamebuf);
             return NULL;
         }
+        Py_BEGIN_ALLOW_THREADS
         hFindFile = FindFirstFileW(wnamebuf, &wFileData);
+        Py_END_ALLOW_THREADS
         if (hFindFile == INVALID_HANDLE_VALUE) {
             int error = GetLastError();
             if (error == ERROR_FILE_NOT_FOUND) {
@@ -2430,7 +2432,9 @@ posix_listdir(PyObject *self, PyObject *args)
     if ((d = PyList_New(0)) == NULL)
         return NULL;
 
+    Py_BEGIN_ALLOW_THREADS
     hFindFile = FindFirstFile(namebuf, &FileData);
+    Py_END_ALLOW_THREADS
     if (hFindFile == INVALID_HANDLE_VALUE) {
         int error = GetLastError();
         if (error == ERROR_FILE_NOT_FOUND)