Skip to content
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

WIP Make kernel message handling async and in order #4697

Merged
merged 79 commits into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
6faa2db
First pass at making all kernel message handling asynchronous and pre…
jasongrout Jun 8, 2018
6d6425b
First pass at handling the case for restarting a kernel and canceling…
jasongrout Jun 8, 2018
6b88d89
Fix comm target callback signature.
jasongrout Jun 8, 2018
e905dd8
WIP update docs
jasongrout Jun 12, 2018
958f91f
Make the IAnyMessage message readonly.
jasongrout Jun 12, 2018
d7ea1bb
Make connectToComm synchronous.
jasongrout Jun 13, 2018
4b545d9
WIP more async kernel message processing work.
jasongrout Jun 13, 2018
c43f2e3
Deal with more async message hook processing.
jasongrout Jun 13, 2018
0112a70
Rename checkCurrentMessage to assertCurrentMessage since it behaves m…
jasongrout Jun 13, 2018
a710f4b
Convert kernel utility functions to use async/await syntax.
jasongrout Jun 13, 2018
17b7aa7
Standardize on async return types being: value | Promise<value>
jasongrout Jun 13, 2018
ee17a1f
Better typing: Promise<void> -> PromiseLike<void>
jasongrout Jun 13, 2018
086c935
The future done promise returns the reply message, so use it.
jasongrout Jun 13, 2018
8a5c58a
More value | Promise<value> -> value | PromiseLike<value> changes.
jasongrout Jun 13, 2018
987bff9
Rate-limit hook list compactions with requestAnimationFrame.
jasongrout Jun 13, 2018
6ae2a93
Add/enhance documentation and comments.
jasongrout Jun 13, 2018
ba3e81e
Documentation updates and code reorganization.
jasongrout Jun 13, 2018
b206730
Fix an anachronism in the code.
jasongrout Jun 13, 2018
cb2b5f8
Message hooks can return promises, so update the type signature.
jasongrout Jun 13, 2018
0c2baf2
Fix some easier TODO items.
jasongrout Jun 14, 2018
dd50e93
Add removeCommTarget and removeMessageHook functions to kernels.
jasongrout Jun 14, 2018
3d58b49
Use async/await for requestKernelInfo
jasongrout Jun 14, 2018
a8883b3
Fix some imports.
jasongrout Jun 14, 2018
6c1f09e
Update the current kernel session id on *every* message.
jasongrout Jun 14, 2018
db9e387
Fix some of the services tests to compile.
jasongrout Jun 14, 2018
d4f1468
await instead of return a promise
jasongrout Jun 15, 2018
555cb73
WIP
jasongrout Jun 15, 2018
bce868b
Prevent console error when a future is canceled.
jasongrout Jun 15, 2018
fbb1af3
WIP
jasongrout Jun 16, 2018
a8e8641
WIP
jasongrout Jun 16, 2018
ba00836
Use phosphor’s defer rather than requestAnimationFrame
jasongrout Jun 16, 2018
15d733a
More WIP migrating tests to async/await.
jasongrout Jun 16, 2018
b73ca7a
A few more logging messages.
jasongrout Jun 16, 2018
a25e24d
Skip comm tests for now
jasongrout Jun 16, 2018
3bf22ad
Re-enable all services tests.
jasongrout Jun 16, 2018
6ec05db
Adjust logging to use a single exported function.
jasongrout Jun 17, 2018
84171f2
Fix message hook test.
jasongrout Jun 18, 2018
15468ab
Fix 404 handling when deleting a kernel.
jasongrout Jun 19, 2018
b151c69
Skip two tests (for now) that rely on kernel status messages in a par…
jasongrout Jun 19, 2018
6e6eedb
asyncify two more tests.
jasongrout Jun 19, 2018
8d2db4a
Fix the serverSettings unit test.
jasongrout Jun 19, 2018
070f017
Audit and clean up session and session manager changes.
jasongrout Jun 20, 2018
bbcb8f7
Fix comm unit tests.
jasongrout Jun 20, 2018
fe33e03
Fix ikernel tests.
jasongrout Jun 21, 2018
39ea199
Fix kernel manager tests.
jasongrout Jun 21, 2018
9a9652e
Fix shutdown of one kernel killing all other connections to the kernel.
jasongrout Jun 21, 2018
2502aa0
Remove the anyMessage ‘different client session’ test.
jasongrout Jun 21, 2018
0e7575b
Fix ikernel tests.
jasongrout Jun 21, 2018
10d3008
Rename the testEmission utility shouldTest argument to find.
jasongrout Jun 21, 2018
e667434
Reset some logging to back the way it was before the PR.
jasongrout Jun 21, 2018
c47d549
Fix session tests.
jasongrout Jun 21, 2018
2ef505f
Add logging of kernel messages for testing.
jasongrout Jun 21, 2018
f5f44fb
Fix kernel interrupt test.
jasongrout Jun 21, 2018
737a096
Fix a kernel test.
jasongrout Jun 21, 2018
a592afe
Add TODO note about hardcoding a URL.
jasongrout Jun 21, 2018
8e771a4
Comment out logging.
jasongrout Jun 21, 2018
1fc95e8
Fix lint issues.
jasongrout Jun 21, 2018
dfad03b
Add notes about sporadically failing tests.
jasongrout Jun 21, 2018
12dd9ea
Fix lint errors.
jasongrout Jun 21, 2018
9fdeae5
Make a copy of the runningKernels list if there is a possibility of d…
jasongrout Jun 22, 2018
db924ae
Don’t preemptively cancel messages from a different kernel session.
jasongrout Jun 22, 2018
fc6b562
Work around issues where tests were sporadically hanging.
jasongrout Jun 22, 2018
9b4c9ab
Put back in debug logging.
jasongrout Jun 22, 2018
f44dde6
Add explanatory notes.
jasongrout Jun 22, 2018
989d66d
Add testResolveOrder and isFulfilled utility functions, and tests.
jasongrout Jun 22, 2018
b40abcd
Kernel message hooks should also accept promises
jasongrout Jun 25, 2018
bdcf02f
Add some async message hooks in the standard tests.
jasongrout Jun 25, 2018
652a26a
Add some tests for patterns, such as testing order of signal emissions.
jasongrout Jun 25, 2018
d96044b
Add asynchronous message handling test, with associated infrastructure.
jasongrout Jun 26, 2018
67f271e
Add transient message data for display updates to the message spec.
jasongrout Jun 26, 2018
be6a65a
Remove kernel message logging
jasongrout Jun 26, 2018
0f3aae2
Definitely start a new kernel before each ikernel test.
jasongrout Jun 26, 2018
353779f
Fix failing kernel test.
jasongrout Jun 26, 2018
bef6212
Some minor cleanup.
jasongrout Jun 26, 2018
4a30e0f
Cleanup based on review comments by @ian-r-rose
jasongrout Jun 26, 2018
8b7b059
Remove testResolveOrder since we did not end up using it.
jasongrout Jun 26, 2018
0c45d74
Move the defer function to where it is being used.
jasongrout Jun 26, 2018
38e96a1
Fix unhandled message test.
jasongrout Jun 26, 2018
58ecc9c
Fix comment to refer to node.
jasongrout Jun 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 17 additions & 10 deletions packages/services/src/kernel/comm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,39 +51,44 @@ class CommHandler extends DisposableDelegate implements Kernel.IComm {
* Get the callback for a comm close event.
*
* #### Notes
* This is called when the comm is closed from either the server or
* client.
* This is called when the comm is closed from either the server or client.
*
* **See also:** [[ICommClose]], [[close]]
*/
get onClose(): (msg: KernelMessage.ICommCloseMsg) => void {
get onClose(): (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void> {
return this._onClose;
}

/**
* Set the callback for a comm close event.
*
* #### Notes
* This is called when the comm is closed from either the server or
* client.
* This is called when the comm is closed from either the server or client. If
* the function returns a promise, and the kernel was closed from the server,
* kernel message processing will pause until the returned promise is
* fulfilled.
*
* **See also:** [[close]]
*/
set onClose(cb: (msg: KernelMessage.ICommCloseMsg) => void) {
set onClose(cb: (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void>) {
this._onClose = cb;
}

/**
* Get the callback for a comm message received event.
*/
get onMsg(): (msg: KernelMessage.ICommMsgMsg) => void {
get onMsg(): (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void> {
return this._onMsg;
}

/**
* Set the callback for a comm message received event.
*
* #### Notes
* This is called when a comm message is received. If the function returns a
* promise, kernel message processing will pause until it is fulfilled.
*/
set onMsg(cb: (msg: KernelMessage.ICommMsgMsg) => void) {
set onMsg(cb: (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void>) {
this._onMsg = cb;
}

Expand Down Expand Up @@ -171,6 +176,8 @@ class CommHandler extends DisposableDelegate implements Kernel.IComm {
let onClose = this._onClose;
if (onClose) {
let ioMsg = KernelMessage.createMessage(options, content, metadata, buffers);
// In the future, we may want to communicate back to the user the possible
// promise returned from onClose.
onClose(ioMsg as KernelMessage.ICommCloseMsg);
}
this.dispose();
Expand All @@ -180,6 +187,6 @@ class CommHandler extends DisposableDelegate implements Kernel.IComm {
private _target = '';
private _id = '';
private _kernel: Kernel.IKernel;
private _onClose: (msg: KernelMessage.ICommCloseMsg) => void;
private _onMsg: (msg: KernelMessage.ICommMsgMsg) => void;
private _onClose: (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void>;
private _onMsg: (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void>;
}