]> granicus.if.org Git - python/commitdiff
Release the GIL during COM method calls, to avoid deadlocks in
authorThomas Heller <theller@ctypes.org>
Sun, 11 Jun 2006 17:04:22 +0000 (17:04 +0000)
committerThomas Heller <theller@ctypes.org>
Sun, 11 Jun 2006 17:04:22 +0000 (17:04 +0000)
Python coded COM objects.

Modules/_ctypes/callproc.c

index 92a6c3c63b2ac81e920dd3e13e438c0bee791515..c4942a0abddf7acecdaacf253571f4b6fb10bb8a 100644 (file)
@@ -804,14 +804,20 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk)
        PyObject *obj;
        TCHAR *text;
 
+       /* We absolutely have to release the GIL during COM method calls,
+          otherwise we may get a deadlock!
+       */
+       Py_BEGIN_ALLOW_THREADS
+
        hr = pIunk->lpVtbl->QueryInterface(pIunk, &IID_ISupportErrorInfo, (void **)&psei);
        if (FAILED(hr))
                goto failed;
+
        hr = psei->lpVtbl->InterfaceSupportsErrorInfo(psei, riid);
        psei->lpVtbl->Release(psei);
-
        if (FAILED(hr))
                goto failed;
+
        hr = GetErrorInfo(0, &pei);
        if (hr != S_OK)
                goto failed;
@@ -822,9 +828,10 @@ GetComError(HRESULT errcode, GUID *riid, IUnknown *pIunk)
        pei->lpVtbl->GetHelpFile(pei, &helpfile);
        pei->lpVtbl->GetSource(pei, &source);
 
+       pei->lpVtbl->Release(pei);
+
   failed:
-       if (pei)
-               pei->lpVtbl->Release(pei);
+       Py_END_ALLOW_THREADS
 
        progid = NULL;
        ProgIDFromCLSID(&guid, &progid);