diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-06-15-09-37-33.bpo-1572968.zftonM.rst b/Misc/NEWS.d/next/Core and Builtins/2019-06-15-09-37-33.bpo-1572968.zftonM.rst new file mode 100644 index 00000000000000..e6c296ca2049dc --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-06-15-09-37-33.bpo-1572968.zftonM.rst @@ -0,0 +1 @@ +Release the GIL in :class:`mmap.mmap`. diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 66ed0b8efb775c..0245a6e04cfafb 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1562,12 +1562,14 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) off_lo = (DWORD)(offset & 0xFFFFFFFF); /* For files, it would be sufficient to pass 0 as size. For anonymous maps, we have to pass the size explicitly. */ + Py_BEGIN_ALLOW_THREADS m_obj->map_handle = CreateFileMappingA(m_obj->file_handle, NULL, flProtect, size_hi, size_lo, m_obj->tagname); + Py_END_ALLOW_THREADS if (m_obj->map_handle != NULL) { m_obj->data = (char *) MapViewOfFile(m_obj->map_handle, dwDesiredAccess,