Skip to content

Commit 689b5d4

Browse files
committed
add test for GIL
1 parent 6becf65 commit 689b5d4

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/test_free_threaded.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
import pytest
6+
7+
8+
def _is_freethreaded_build():
9+
import sysconfig
10+
return bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
11+
12+
13+
@pytest.mark.skipif(not _is_freethreaded_build(), reason="requires free-threaded Python build")
14+
def test_evdev_does_not_reenable_gil():
15+
result = subprocess.run(
16+
[sys.executable, "-c", "import sys; import evdev; assert not sys._is_gil_enabled()"],
17+
capture_output=True,
18+
text=True,
19+
env={**os.environ, "PYTHON_GIL": "0"},
20+
)
21+
assert result.returncode == 0, f"evdev re-enabled the GIL:\n{result.stderr}"

0 commit comments

Comments
 (0)