Skip to content

More robust solution to execute queueing #8651

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

Merged
merged 13 commits into from
Jan 7, 2022
Merged

Conversation

rchiodo
Copy link
Contributor

@rchiodo rchiodo commented Jan 7, 2022

For #8322

This implements the 'delayed' future so that it's impossible to send more than one requestExecute at a time.

Tested locally and it works but doing this separately so that it can be reverted if it causes something to break.

@rchiodo rchiodo requested a review from a team as a code owner January 7, 2022 01:33
@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2022

Codecov Report

Merging #8651 (cc49d5e) into main (22e2ed6) will decrease coverage by 0%.
The diff coverage is 65%.

@@          Coverage Diff           @@
##            main   #8651    +/-   ##
======================================
- Coverage     71%     71%    -1%     
======================================
  Files        382     384     +2     
  Lines      24523   24624   +101     
  Branches    3767    3789    +22     
======================================
+ Hits       17549   17611    +62     
- Misses      5449    5477    +28     
- Partials    1525    1536    +11     
Impacted Files Coverage Δ
...lient/datascience/jupyter/kernels/cellExecution.ts 73% <50%> (+<1%) ⬆️
src/client/datascience/delayedFutureExecute.ts 58% <58%> (ø)
src/client/datascience/chainingExecuteRequester.ts 93% <93%> (ø)
src/client/datascience/baseJupyterSession.ts 76% <100%> (+<1%) ⬆️
src/client/datascience/dataScienceSurveyBanner.ts 69% <0%> (-7%) ⬇️
...t/datascience/notebook/vscodeNotebookController.ts 79% <0%> (-1%) ⬇️
...ent/common/application/webviewViews/webviewView.ts 78% <0%> (+10%) ⬆️
...ience/variablesView/variableViewMessageListener.ts 100% <0%> (+22%) ⬆️

@rchiodo
Copy link
Contributor Author

rchiodo commented Jan 7, 2022

A restart test seems to be failing on all versions. Not sure why. I'm investigating now (hopefully it repros locally)

@@ -217,7 +219,8 @@ export abstract class BaseJupyterSession implements IJupyterSession {
if (!this.session?.kernel) {
throw new SessionDisposedError();
}
return this.session.kernel.requestExecute(content, disposeOnDone, metadata);
// Make sure to chain the executes
return this.chainingExecute.requestExecute(this.session.kernel, content, disposeOnDone, metadata);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (not sure myself). If this QT event loop can't handle the queuing would we also need this chain on the other request functions here? Like requestDebug and requestInspect?

Copy link
Contributor Author

@rchiodo rchiodo Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. It might, but we don't send requestDebug/requestInspect in multiple spots. And requestInspect at the same time as requestExecute does work with QT5. At least I couldn't break it with the variables tab open.

private metadata?: JSONObject
) {
// Setup our request based on the previous link finishing
if (previousLink) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is minor, but was wondering on the typing here a tiny bit. Aren't we guaranteed a previousLink at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah that's true. I can skip the if check.

// If the kernel dies, finish our future
this.statusChangedHandler = (_session: Kernel.IKernelConnection, status: KernelMessage.Status) => {
if (status === 'unknown' || status === 'restarting' || status === 'dead') {
this.doneDeferred.reject(new CancellationError());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a cancellation error? Also if we are looking at 'restarting' we probably need 'autorestarting' as well since Jupyter has both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I should add 'autorestarting'.

CancellationError is what Jupyter throws on the 'done' promise when the kernel is shutdown

return this.requestFuture.msg;
}
return {
content: this.content,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check my understanding, this path (where the requestFuture is not define) is basically just a dummy placeholder until the previous execute finished right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's correct. I don't think any of our code ever reads 'msg' anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, the values for it just didn't quite make sense, so just wanted to confirm that it was a dummy value (essentially).

Copy link
Member

@IanMatthewHuff IanMatthewHuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a couple of questions (just 'cause these futures can get a bit hairy) but I think that it looks good.

@rchiodo rchiodo merged commit 9bdaf87 into main Jan 7, 2022
@rchiodo rchiodo deleted the rchiodo/qt5_delayedFuture branch January 7, 2022 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants