-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
Release the GIL while creating a Session. #13127
Release the GIL while creating a Session. #13127
Conversation
// held. | ||
let scheduler = scheduler.scheduler(py).clone(); | ||
let cancellation_latch = cancellation_latch.cancelled(py).clone(); | ||
let session = py.allow_threads(|| Session::new( |
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.
Is there any way to ensure the "no GIL" condition for Graph
access? Should Graph
methods panic if the GIL is held?
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.
Hm... good idea. But I don't see a way to check whether the GIL is already acquired, and it's probably not worth adding thread local state for it.
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.
PyO3 exposes the necessary API:
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.
Good call. Yea, I think peppering a reusable debug assert around would be a great idea. I'll do that in a followup though, since it would be hard to cherry pick.
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.
👍
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
ca44195
to
576dee5
Compare
Creating a `Session` accesses the `Graph` to get the number of valid nodes, but when created under the `PySession` wrapper, does so while holding the GIL. Release the GIL in `PySession`. [ci skip-build-wheels] Conflicts: [ci skip-jvm-tests]
Creating a `Session` accesses the `Graph` to get the number of valid nodes, but when created under the `PySession` wrapper, does so while holding the GIL. Release the GIL in `PySession`. [ci skip-build-wheels]
Creating a
Session
accesses theGraph
to get the number of valid nodes, but when created under thePySession
wrapper, does so while holding the GIL.Release the GIL in
PySession
.[ci skip-build-wheels]