[Python-checkins] closes bpo-31903: Release the GIL when calling into SystemConfiguration (GH-4178)

Benjamin Peterson webhook-mailer at python.org
Tue Sep 11 19:14:03 EDT 2018


https://github.com/python/cpython/commit/4859ba0d2ce4506fddc3f55f90f8dce031b3804f
commit: 4859ba0d2ce4506fddc3f55f90f8dce031b3804f
branch: master
author: Max Bélanger <aeromax at gmail.com>
committer: Benjamin Peterson <benjamin at python.org>
date: 2018-09-11T16:14:00-07:00
summary:

closes bpo-31903: Release the GIL when calling into SystemConfiguration (GH-4178)

files:
A Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst
M Modules/_scproxy.c

diff --git a/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst b/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst
new file mode 100644
index 000000000000..3788112cd730
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst
@@ -0,0 +1,2 @@
+In :mod:`_scproxy`, drop the GIL when calling into ``SystemConfiguration`` to avoid
+deadlocks.
diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c
index 8861dc456d75..dbee3f7367ed 100644
--- a/Modules/_scproxy.c
+++ b/Modules/_scproxy.c
@@ -62,7 +62,10 @@ get_proxy_settings(PyObject* Py_UNUSED(mod), PyObject *Py_UNUSED(ignored))
     PyObject* v;
     int r;
 
+    Py_BEGIN_ALLOW_THREADS
     proxyDict = SCDynamicStoreCopyProxies(NULL);
+    Py_END_ALLOW_THREADS
+
     if (!proxyDict) {
         Py_RETURN_NONE;
     }
@@ -172,7 +175,10 @@ get_proxies(PyObject* Py_UNUSED(mod), PyObject *Py_UNUSED(ignored))
     int r;
     CFDictionaryRef proxyDict = NULL;
 
+    Py_BEGIN_ALLOW_THREADS
     proxyDict = SCDynamicStoreCopyProxies(NULL);
+    Py_END_ALLOW_THREADS
+
     if (proxyDict == NULL) {
         return PyDict_New();
     }



More information about the Python-checkins mailing list