diff --git a/Misc/NEWS.d/next/Library/2022-10-10-09-52-21.gh-issue-44098.okcqJt.rst b/Misc/NEWS.d/next/Library/2022-10-10-09-52-21.gh-issue-44098.okcqJt.rst new file mode 100644 index 00000000000000..4efea4a7c4fccc --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-10-10-09-52-21.gh-issue-44098.okcqJt.rst @@ -0,0 +1 @@ +Release the GIL when creating :class:`mmap.mmap` objects on Unix. diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 5c05aa738ef564..fdce783fdec5e2 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1318,9 +1318,9 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) } } - m_obj->data = mmap(NULL, map_size, - prot, flags, - fd, offset); + Py_BEGIN_ALLOW_THREADS + m_obj->data = mmap(NULL, map_size, prot, flags, fd, offset); + Py_END_ALLOW_THREADS if (devzero != -1) { close(devzero);