Skip to content
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

Add free-threading support #462

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Aug 23, 2024

This is an attempt to address #460. Mostly, I followed the instructions that @AA-Turner linked to there.

I looked over _speedups.c. My non-expert eye did not see anything that didn't look nogil-safe, so I just added the Py_MOD_GIL_NOT_USED declaration to the extension module.

The matrix in the tests.yaml workflow has been expanded to included free-threading versions of python3.13 under Linux and Windows.
The Linux tests work.
The Windows tests do not, for reasons that I do not understand.

I played with enabling free-threading cibuildwheel builds in a separate branch, and that seems to just work. (Though I have not tested any of the resulting wheels to verify that they are usable.)

Fixes #460

@dairiki
Copy link
Contributor Author

dairiki commented Aug 23, 2024

In the Windows free-threading test, pytest appears to fail with

Exception ignored on threading shutdown:
Traceback (most recent call last):
  File "C:\Python313\Lib\threading.py", line 1524, in _shutdown
    if _main_thread._handle.is_done() and _is_main_interpreter():
  py313: FAIL code 32[21](https://github.com/dairiki/markupsafe/actions/runs/10529464771/job/29177296179#step:7:22)225477 (19.61=setup[18.12]+cmd[0.03,1.46] seconds)
SystemError: <method 'is_done' of '_thread._ThreadHandle' objects> returned a result with an exception set

I have no idea what that might be about.
(I have no Windows system available on which to play around locally so further investigation is not easy.)

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.

Please could markupsafe._speedups declare support (or lack thereof) for free-threaded Python?
1 participant