Skip to content

Commit

Permalink
closes bpo-31903: Release the GIL when calling into SystemConfigurati…
Browse files Browse the repository at this point in the history
…on (GH-4178)

(cherry picked from commit 4859ba0)

Co-authored-by: Max Bélanger <aeromax@gmail.com>
  • Loading branch information
miss-islington and maxbelanger committed Sep 12, 2018
1 parent cadb66e commit 72c34cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In :mod:`_scproxy`, drop the GIL when calling into ``SystemConfiguration`` to avoid
deadlocks.
6 changes: 6 additions & 0 deletions Modules/_scproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ get_proxy_settings(PyObject* mod __attribute__((__unused__)))
PyObject* v;
int r;

Py_BEGIN_ALLOW_THREADS
proxyDict = SCDynamicStoreCopyProxies(NULL);
Py_END_ALLOW_THREADS

if (!proxyDict) {
Py_RETURN_NONE;
}
Expand Down Expand Up @@ -172,7 +175,10 @@ get_proxies(PyObject* mod __attribute__((__unused__)))
int r;
CFDictionaryRef proxyDict = NULL;

Py_BEGIN_ALLOW_THREADS
proxyDict = SCDynamicStoreCopyProxies(NULL);
Py_END_ALLOW_THREADS

if (proxyDict == NULL) {
return PyDict_New();
}
Expand Down

0 comments on commit 72c34cf

Please sign in to comment.