forked from michaelhly/pyo3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make PyClassBorrowChecker thread safe (PyO3#4544)
* use a mutex in PyClassBorrowChecker * add a test that triggers a reference race * make BorrowFlag wrap an AtomicUsize * fix errors seen on CI * add changelog entry * use a compare-exchange loop in try_borrow * move atomic increment implementation into increment method * fix bug pointed out in code review * make test use an atomic * make test runnable on GIL-enabled build * use less restrictive ordering, add comments * fix ruff error * relax ordering in mutable borrows as well * Update impl_.rs Co-authored-by: David Hewitt <[email protected]> * fix path * use AcqRel for mutable borrow compare_exchange loop * add test from david * one more test * disable thread safety tests on WASM * skip python test on WASM as well * fix format * fixup skipif reason --------- Co-authored-by: David Hewitt <[email protected]>
- Loading branch information
1 parent
71012db
commit 8288fb9
Showing
4 changed files
with
192 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Refactored runtime borrow checking for mutable pyclass instances | ||
to be thread-safe when the GIL is disabled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters