Skip to content

Don't define Py_LIMITED_API and don't re-enable GIL under free-threading #3482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# 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 [],
)
]

Expand Down
22 changes: 19 additions & 3 deletions tornado/speedups.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}