From: Lysandros Nikolaou Date: Thu, 1 May 2025 18:42:30 +0000 (+0200) Subject: build: Fix free-threaded build, mark speedups module as no-GIL X-Git-Tag: v6.5.0~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8e0d36ebad1a042866a9355959e99e0bf90a3c0;p=thirdparty%2Ftornado.git build: Fix free-threaded build, mark speedups module as no-GIL --- diff --git a/setup.py b/setup.py index de6cd3f0..e2a69912 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,7 @@ if ( # Use the stable ABI so our wheels are compatible across python # versions. py_limited_api=can_use_limited_api, - define_macros=[("Py_LIMITED_API", "0x03090000")], + define_macros=[("Py_LIMITED_API", "0x03090000")] if can_use_limited_api else [], ) ] diff --git a/tornado/speedups.c b/tornado/speedups.c index 525d6603..992c29c1 100644 --- a/tornado/speedups.c +++ b/tornado/speedups.c @@ -51,20 +51,36 @@ static PyObject* websocket_mask(PyObject* self, PyObject* args) { return result; } +static int speedups_exec(PyObject *module) { + return 0; +} + static PyMethodDef methods[] = { {"websocket_mask", websocket_mask, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} }; +static PyModuleDef_Slot slots[] = { + {Py_mod_exec, speedups_exec}, +#if (!defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030c0000) || Py_LIMITED_API >= 0x030c0000 + {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED}, +#endif +#if (!defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030d0000) || Py_LIMITED_API >= 0x030d0000 + {Py_mod_gil, Py_MOD_GIL_NOT_USED}, +#endif + {0, NULL} +}; + static struct PyModuleDef speedupsmodule = { PyModuleDef_HEAD_INIT, "speedups", NULL, - -1, - methods + 0, + methods, + slots, }; PyMODINIT_FUNC PyInit_speedups(void) { - return PyModule_Create(&speedupsmodule); + return PyModuleDef_Init(&speedupsmodule); }