Skip to content

Gil management#1

Merged
andreaTP merged 2 commits into
mainfrom
gil-management
Jun 11, 2026
Merged

Gil management#1
andreaTP merged 2 commits into
mainfrom
gil-management

Conversation

@andreaTP

@andreaTP andreaTP commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

andreaTP and others added 2 commits June 8, 2026 21:22
ThreadSafetyTest (3 tests): concurrent exec, concurrent invokeFunction,
and callbacks during concurrent access. These crashed the JVM (SIGABRT)
before the fix.

LibPython: add PyEval_SaveThread, PyGILState_Ensure, PyGILState_Release
bindings (all Stable ABI since Python 3.2). Remove dead PyErr_Fetch.

PythonEngine: release GIL after initialization via PyEval_SaveThread.
Wrap exec(), invokeFunction() (both overloads) with GILState ensure/
release. close() acquires GIL but does not release after Py_FinalizeEx
(finalization invalidates all thread states). FunctionDispatcher
unchanged (GIL already held by CPython during callbacks).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add virtualThreadsInvokeFunction test (8 virtual threads)
- Add mixedPlatformAndVirtualThreads test (2 platform + 4 virtual)
- All 5 thread safety tests pass: GIL ensure/release pins virtual
  threads to their carrier during native calls automatically
- Document thread safety in README

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@andreaTP andreaTP merged commit 6f81f06 into main Jun 11, 2026
5 checks passed
@andreaTP andreaTP deleted the gil-management branch June 11, 2026 09:32
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.

1 participant