Skip to content

Fix GIL warning in free-threaded Python - #49

Merged
hzhangxyz merged 2 commits into
mainfrom
copilot/fix-gil-warning-python
Nov 27, 2025
Merged

Fix GIL warning in free-threaded Python#49
hzhangxyz merged 2 commits into
mainfrom
copilot/fix-gil-warning-python

Conversation

Copilot AI commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

The apyds._ds module triggers a RuntimeWarning in free-threaded Python (PEP 703) because it doesn't declare GIL safety.

RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'apyds._ds', which has not declared that it can run safely without the GIL.

Changes

  • Add py::mod_gil_not_used() to the PYBIND11_MODULE declaration in apyds/ds.cc
PYBIND11_MODULE(_ds, m, py::mod_gil_not_used()) {

This is the standard pybind11 approach (2.13+) for declaring free-threading compatibility.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix warning in free threading python.</issue_title>
<issue_description>```
:491
:491: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'apyds._ds', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.


## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 27, 2025
Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
@hzhangxyz
hzhangxyz marked this pull request as ready for review November 27, 2025 12:18
Copilot AI changed the title [WIP] Fix warning related to global interpreter lock in Python Fix GIL warning in free-threaded Python Nov 27, 2025
Copilot AI requested a review from hzhangxyz November 27, 2025 12:19
@hzhangxyz
hzhangxyz merged commit 65143f0 into main Nov 27, 2025
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix warning in free threading python.

2 participants