Skip to content

Add no-GIL interpreter support #641

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

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

Add no-GIL interpreter support #641

wants to merge 11 commits into from

Conversation

clin1234
Copy link

No description provided.

clin1234 added 4 commits July 20, 2025 11:33
Add `pytest-run-parallel` as dependency, test no-GIL interpreters in CI, and
mark Cython module as safe for freethreaded interpreters.
Copy link

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @clin1234! Thanks for working on this. I'm not the maintainer here, but I'm leaving a couple of comments to help move this forward.

@@ -0,0 +1,51 @@
#!/usr/bin/env python3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to #613 (comment), sharing Packer objects wouldn't be supported under free-threading, so this test is probably not needed. Could we run the test suite with pytest-run-parallel instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever works: I borrowed this test from another fork, and I'm still learning how to modernize existing pytest tests to use pytest-run-parallel

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I would do is install pytest-run-parallel in CI and then add a step in the main test job that looks something like this:

- name: Install pytest-run-parallel under free-threading
  if: matrix.py == '3.14t-dev' || matrix.py == '3.13t'
  shell: bash
  run: |
    pip install pytest-run-parallel

- name: Run tests in parallel under free-threading
  if: matrix.py == '3.14t-dev' || matrix.py == '3.13t'
  shell: bash
  run: |
    pytest -v --parallel-threads=auto --iterations=20 test

Copy link

@lysnikolaou lysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating on this so quickly @clin1234! Left some more comments on here. Hope these are helpful!

@@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
py: ["3.14-dev", "3.13", "3.12", "3.11", "3.10", "3.9"]
py: ["3.14-dev", "3.14t-dev", "3.13", "3.13t", "3.12", "3.11", "3.10", "3.9", "3.8"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if adding 3.8 here is a good idea, since it's unrelated to the purpose of the PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has upstream dropped 3.8 yet?

requirements.txt Outdated
@@ -1 +1,2 @@
Cython~=3.1.2
pytest-run-parallel[psutil]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like pytest is not listed as a requirement here, so maybe it's better to remove pytest-run-parallel from here and install it in CI directly?

@@ -17,7 +17,7 @@ def test_unpack_bytearray():
obj = unpackb(buf, use_list=1)
assert [b"foo", b"bar"] == obj
expected_type = bytes
assert all(type(s) == expected_type for s in obj)
assert all(type(s) is expected_type for s in obj)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These also seem unrelated to the purpose of the PR (adding support for free-threading).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed lints as well in this PR

@@ -0,0 +1,51 @@
#!/usr/bin/env python3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I would do is install pytest-run-parallel in CI and then add a step in the main test job that looks something like this:

- name: Install pytest-run-parallel under free-threading
  if: matrix.py == '3.14t-dev' || matrix.py == '3.13t'
  shell: bash
  run: |
    pip install pytest-run-parallel

- name: Run tests in parallel under free-threading
  if: matrix.py == '3.14t-dev' || matrix.py == '3.13t'
  shell: bash
  run: |
    pytest -v --parallel-threads=auto --iterations=20 test

On Windows, attempting to upgrade `pip` within CI always yields this:
```
Run pip install -U pip
Requirement already satisfied: pip in c:\hostedtoolcache\windows\python\3.10.11\x64\lib\site-packages (25.1.1)
Collecting pip
  Downloading pip-25.2-py3-none-any.whl.metadata (4.7 kB)
Downloading pip-25.2-py3-none-any.whl (1.8 MB)
   ---------------------------------------- 1.8/1.8 MB 48.1 MB/s eta 0:00:00

Notice:  A new release of pip is available: 25.1.1 -> 25.2
Notice:  To update, run: python.exe -m pip install --upgrade pip
ERROR: To modify pip, please run the following command:
C:\hostedtoolcache\windows\Python\3.10.11\x64\python.exe -m pip install -U pip
Error: Process completed with exit code 1.
```
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.

2 participants