-
Notifications
You must be signed in to change notification settings - Fork 778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn calls of __traverse__ into no-ops for unsendable pyclass if on the wrong thread #3689
Conversation
d14e3b8
to
8ef1d1e
Compare
CodSpeed Performance ReportMerging #3689 will not alter performanceComparing 🎉 Hooray!
|
@JRRudy1 Could you use a dependency specification like pyo3 = { git = "https://github.com/PyO3/pyo3.git", branch = "unsendable-threadsafe-traverse" } and verify that this would work for your use case? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, nice! Looks straightforward enough.
I wonder if there's a way to add a test for this. I suspect the most reasonable option, if we felt it worth it, would be to add a test which manually calls the traverse slot?
Will give it a try. I also noticed that this should be mentioned in the guide... |
2f37419
to
0435ce0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, thanks, great test 👍
…he wrong thread Adds a "threadsafe" variant of `PyCell::try_borrow` which will fail instead of panicking if called on the wrong thread and use it in `call_traverse` to turn GC traversals of unsendable pyclasses into no-ops if on the wrong thread. This can imply leaking the underlying resource if the originator thread has already exited so that the GC will never run there again, but it does avoid hard aborts as we cannot raise an exception from within `call_traverse`.
0435ce0
to
4dc6c16
Compare
Adds a "threadsafe" variant of
PyCell::try_borrow
which will fail instead of panicking if called on the wrong thread and use it incall_traverse
to turn GC traversals of unsendable pyclasses into no-ops if on the wrong thread.This can imply leaking the underlying resource if the originator thread has already exited so that the GC will never run there again, but it does avoid hard aborts as we cannot raise an exception from within
call_traverse
.Closes #3688