Skip to content

Commit

Permalink
pythongh-116749: Disable GIL by default in free-threaded build
Browse files Browse the repository at this point in the history
Switch GIL to disabled by default in free-threaded build so that the
free-threaded CIs catch thread-safety issues.
  • Loading branch information
colesbury committed Apr 25, 2024
1 parent d5df252 commit 9fc88f4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_cmd_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ def test_pythondevmode_env(self):
def test_python_gil(self):
cases = [
# (env, opt, expected, msg)
(None, None, 'None', "no options set"),
(None, None, '0', "no options set"),
('0', None, '0', "PYTHON_GIL=0"),
('1', None, '1', "PYTHON_GIL=1"),
('1', '0', '0', "-X gil=0 overrides PYTHON_GIL=1"),
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
if support.Py_DEBUG:
CONFIG_COMPAT['run_presite'] = None
if support.Py_GIL_DISABLED:
CONFIG_COMPAT['enable_gil'] = -1
CONFIG_COMPAT['enable_gil'] = 0
if MS_WINDOWS:
CONFIG_COMPAT.update({
'legacy_windows_stdio': 0,
Expand Down
2 changes: 1 addition & 1 deletion Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ _PyConfig_InitCompatConfig(PyConfig *config)
config->code_debug_ranges = 1;
config->cpu_count = -1;
#ifdef Py_GIL_DISABLED
config->enable_gil = _PyConfig_GIL_DEFAULT;
config->enable_gil = _PyConfig_GIL_DISABLE;
#endif
}

Expand Down

0 comments on commit 9fc88f4

Please sign in to comment.