[Python-checkins] GH-104308: socket.getnameinfo should release the GIL (#104307)

njsmith webhook-mailer at python.org
Mon May 8 19:27:30 EDT 2023


https://github.com/python/cpython/commit/faf196213e60d8a90773e9e5680d3252bd294643
commit: faf196213e60d8a90773e9e5680d3252bd294643
branch: main
author: Nathaniel J. Smith <njs at pobox.com>
committer: njsmith <njs at pobox.com>
date: 2023-05-08T16:27:20-07:00
summary:

GH-104308: socket.getnameinfo should release the GIL (#104307)

* socket.getnameinfo should release the GIL

* 📜🤖 Added by blurb_it.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>

files:
A Misc/NEWS.d/next/Library/2023-05-08-20-57-17.gh-issue-104307.DSB93G.rst
M Modules/socketmodule.c

diff --git a/Misc/NEWS.d/next/Library/2023-05-08-20-57-17.gh-issue-104307.DSB93G.rst b/Misc/NEWS.d/next/Library/2023-05-08-20-57-17.gh-issue-104307.DSB93G.rst
new file mode 100644
index 000000000000..03775845450c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-05-08-20-57-17.gh-issue-104307.DSB93G.rst
@@ -0,0 +1 @@
+:func:`socket.getnameinfo` now releases the GIL while contacting the DNS server
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 60219593be61..c11fb4400eab 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -6883,8 +6883,10 @@ socket_getnameinfo(PyObject *self, PyObject *args)
         }
 #endif
     }
+    Py_BEGIN_ALLOW_THREADS
     error = getnameinfo(res->ai_addr, (socklen_t) res->ai_addrlen,
                     hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), flags);
+    Py_END_ALLOW_THREADS
     if (error) {
         socket_state *state = get_module_state(self);
         set_gaierror(state, error);



More information about the Python-checkins mailing list