Skip to content

Commit a61870e

Browse files
gh-94637: Release GIL in SSLContext.set_default_verify_paths (GH-94658)
(cherry picked from commit 78307c7) Co-authored-by: Christian Heimes <[email protected]>
1 parent 7a34172 commit a61870e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:meth:`SSLContext.set_default_verify_paths` now releases the GIL around
2+
``SSL_CTX_set_default_verify_paths`` call. The function call performs I/O
3+
and CPU intensive work.

Modules/_ssl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4305,7 +4305,11 @@ static PyObject *
43054305
_ssl__SSLContext_set_default_verify_paths_impl(PySSLContext *self)
43064306
/*[clinic end generated code: output=0bee74e6e09deaaa input=35f3408021463d74]*/
43074307
{
4308-
if (!SSL_CTX_set_default_verify_paths(self->ctx)) {
4308+
int rc;
4309+
Py_BEGIN_ALLOW_THREADS
4310+
rc = SSL_CTX_set_default_verify_paths(self->ctx);
4311+
Py_END_ALLOW_THREADS
4312+
if (!rc) {
43094313
_setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__);
43104314
return NULL;
43114315
}

0 commit comments

Comments
 (0)