free threading: do not enable GIL (#775)

fix #766
This commit is contained in:
Inada Naoki
2026-02-10 12:12:18 +09:00
committed by GitHub
parent d0371b2044
commit aeff560b73
2 changed files with 14 additions and 1 deletions

View File

@@ -21,6 +21,17 @@ Or when you have question about MySQL/MariaDB:
* [MySQL Support](https://dev.mysql.com/support/)
* [Getting Help With MariaDB](https://mariadb.com/kb/en/getting-help-with-mariadb/)
## Free threading Python
> [!NOTE]
> The support for Free threading Python is experimental.
Since v2.2.8, free threading is supported when importing the extension module. Therefore, importing MySQLdb does not acquire GIL.
However, this library does not support simultaneous operations on a single Connection object from multiple threads, regardless of free threading, and the behavior in such cases remains undefined.
> [!WARNING]
> Do not use a single Connection object from multiple threads simultaneously.
## Install

View File

@@ -2911,7 +2911,9 @@ PyInit__mysql(void)
module = PyModule_Create(&_mysqlmodule);
if (!module) return module; /* this really should never happen */
#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
if (!(dict = PyModule_GetDict(module))) goto error;
if (PyDict_SetItemString(dict, "version_info",
PyRun_String(QUOTE(version_info), Py_eval_input,