-
-
Notifications
You must be signed in to change notification settings - Fork 640
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
Use an isolated clone of the Session in workunit handlers to shield against cancellation #11721
Use an isolated clone of the Session in workunit handlers to shield against cancellation #11721
Conversation
# Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
…d be associated with a Session but not canceled by it. # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
The commits are useful to review independently. |
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.
Excellent! Thanks Stu.
fn session_isolated_shallow_clone(py: Python, session_ptr: PySession) -> CPyResult<PySession> { | ||
with_session(py, session_ptr, |session| { | ||
PySession::create_instance(py, session.isolated_shallow_clone()) | ||
}) | ||
} |
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.
Generally, I am curious if we'll be able to move free functions like this onto methods defined on PySession
? Totally okay to not do in this PR - it's a followup project I want to explore to see if it further simplifies our FFI.
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.
Yes, we probably can. The with_$x
context managers add a bunch of noise, and are much less central than calling allow_threads
, which we should try to do in nearly all cases.
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.
Opened #11722
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.
lgtm
Problem
As described in #11715, streaming workunit handler callbacks currently use the same
Session
object as is used in the foreground because they need access to the metrics generated there. But this means that they have the same UI settings as the foreground, and when the foreground is cancelled, they are too.Solution
Split the
Session
object intoSessionHandle
andSessionState
to allow for a shallow clone of theSession
that is isolated in terms of cancellation and UI.Then, use an
isolated_shallow_clone
in theStreamingWorkunitHandler
so that it can continue to consume metrics and execute work (without a UI) after the client has gone away.Result
Fixes #11715.
[ci skip-build-wheels]