pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.34k stars 638 forks source link

use `GILProtected` to synchronize access to various `pyclass` types #21670

Closed tdyas closed 2 days ago

tdyas commented 3 days ago

As part of upgrading to PyO3 v0.23.x, access topyclass-annotated types will no longer be implicitly synchronized against the Python GIL. Those pyclass-annotated types must now be Sync and provide that synchronization explicitly.

Several places in Pants use RefCell which is not Send/Sync by itself. This PR uses pyo3::sync::GILProtected to provide explicit synchronization against the GIL for those use cases. (Eventually, we may wish to not use GILProtected to enable use of the Python 3.13 "no GIL" free threaded build, but that day is not today.)

Migration guide