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

Add Poll class, fix some tests, throttle polling. #6141

Merged
merged 142 commits into from Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
1220ab5
Remove `line()` function which is superfluous because of String.proto…
afshin Feb 19, 2019
11c0d7d
Clean up doc strings in running extension.
afshin Feb 19, 2019
77d61b0
Update session manager to use async.
afshin Feb 20, 2019
b5919f6
Add Poll class to automatically poll and exponentially back off of fa…
afshin Feb 21, 2019
0972f60
Document polling and fix logic.
afshin Feb 21, 2019
4ce59a8
Update kernel manager to use poll class.
afshin Feb 21, 2019
ecb33c6
Improve warning when poll is rejected.
afshin Feb 21, 2019
55c9163
Update polling logic: check if disposed after poll promise resolves o…
afshin Feb 22, 2019
b554c1e
Add optional name to poll for console output.
afshin Feb 25, 2019
89d6329
Use poll class in terminal manager.
afshin Feb 25, 2019
884c0ad
Update poll names.
afshin Feb 25, 2019
3621f2b
Add support for `when` promise in poll instantiation.
afshin Feb 25, 2019
4d225c8
Update terminal manager.
afshin Feb 25, 2019
a012b4a
Add `when` promise to session and kernel managers.
afshin Feb 25, 2019
4ceaff4
Update shutdown logic.
afshin Feb 26, 2019
6dd0811
Add support for poll interval variance.
afshin Feb 26, 2019
e982a8a
Log when poll reconnects. wobble => jitter
afshin Feb 27, 2019
d30ac05
Always send XSRF token if available. Fixes 403 bug after reconnects.
afshin Feb 27, 2019
e4768cd
Support poll refreshing.
afshin Feb 27, 2019
b8cab09
Update polling logic.
afshin Feb 28, 2019
8867d02
Update poll logic.
afshin Feb 28, 2019
576cd68
Define Poll.Next type.
afshin Feb 28, 2019
008e89f
Update doc strings.
afshin Feb 28, 2019
5b8651a
Add support for max poll interval.
afshin Feb 28, 2019
7c127e3
Clean up poll class, make min/max public, change `poll` argument to `…
afshin Mar 1, 2019
1d40e96
Add `payload` and `disposed` signals to the poll class.
afshin Mar 1, 2019
03bb527
Change `payload` to `resolved` and add a `rejected` signal.
afshin Mar 1, 2019
5ab8a5e
Add poll `tick` and `ticked`.
afshin Mar 1, 2019
231f576
Update poll chain logic.
afshin Mar 4, 2019
1ce6bec
Emit signals only after the next poll promise is scheduled.
afshin Mar 4, 2019
d66e055
Re-schedule poll execution if document is hidden.
afshin Mar 4, 2019
d0a827a
Clean up.
afshin Mar 4, 2019
c5dd256
Add schedule from `standby` state.
afshin Mar 4, 2019
7fd8b03
Use poll refresh to trigger terminal manager refresh.
afshin Mar 4, 2019
d40a63f
More clean up and async in services.
afshin Mar 4, 2019
3184488
Better document Poll#next.
afshin Mar 4, 2019
c925007
Remove `_ready` and `_isReady` and instead set _outstanding in the po…
afshin Mar 4, 2019
fb40f46
Clean up poll class.
afshin Mar 4, 2019
48d6747
Since connected is always available, make it a public attribute inste…
afshin Mar 4, 2019
79dc3fb
Audit disposed flag after every asynchronous action. Catch promise re…
afshin Mar 5, 2019
a380476
Add initial poll test.
afshin Mar 5, 2019
9b43abb
#next can always return a call to schedule and rely on that function …
afshin Mar 5, 2019
7b5fe9d
Change `schedule` to `origin`; it is clearer.
afshin Mar 5, 2019
8fb9dd3
Update polling API, simplify signals. Reveal more state.
afshin Mar 5, 2019
3753994
More simplification and clean up of poll class.
afshin Mar 5, 2019
5b32d95
Synchronize poll state, ticks, and next promise resolutions.
afshin Mar 6, 2019
9ec5351
Remove `Poll.Next` concept and simply resolve #next and #refresh() pr…
afshin Mar 6, 2019
a8bb3a3
Update poll documentation.
afshin Mar 6, 2019
efb14f6
#refresh() should return a promise.
afshin Mar 6, 2019
925860d
Use variable name "poll" and "next" for PromiseDelegate instances coh…
afshin Mar 7, 2019
582966c
Use poll in status bar memory usage.
afshin Mar 7, 2019
543f89a
Simplify poll class.
afshin Mar 8, 2019
76e4b5f
Simplify poll class, continued.
afshin Mar 8, 2019
d5ee4e3
Add poll start and stop methods.
afshin Mar 8, 2019
6a437c1
Clean up poll dispose.
afshin Mar 8, 2019
b7065c5
Add documentation notes that indicate poll ticks as little as it can.
afshin Mar 8, 2019
0f01313
Clean up poll API and handle waiting for `when` promise to resolve.
afshin Mar 9, 2019
1480823
Add more poll tests.
afshin Mar 11, 2019
1b0f40b
Update poll tests.
afshin Mar 11, 2019
07c6fea
Update when-resolved, when-rejected to instantiated-resolved, instant…
afshin Mar 11, 2019
8ef1871
Update poll tests.
afshin Mar 11, 2019
7cc8152
Fix poll stop behavior.
afshin Mar 11, 2019
a63e444
Update poll tests.
afshin Mar 11, 2019
a249193
Handle case where an environment may have set `document` to `null`.
afshin Mar 11, 2019
4f405f9
Handle situation where `document` is set to `null` by an environment.
afshin Mar 15, 2019
a6d1cda
Parameterize `standby` of polls.
afshin Mar 15, 2019
d583b98
Update tests to use `standby='never'`.
afshin Mar 15, 2019
77eff05
Fix shutdown signal emission logic.
afshin Mar 15, 2019
9508938
After shutdown, entities ought to be disposed.
afshin Mar 15, 2019
5636cbf
Make onActivateRequest test of code console synchronous.
afshin Mar 15, 2019
837ee7f
Use it.skip()
afshin Mar 20, 2019
c9373c2
Add Dialog.nuke (experimental)
afshin Mar 20, 2019
308ea87
Try Travis.
afshin Mar 20, 2019
029e41c
Rename to Dialog.flush().
afshin Mar 21, 2019
bc984ef
Test acceptDialog (temp WIP)
afshin Mar 22, 2019
956268f
Add a tracker for all dialogs.
afshin Mar 22, 2019
9819606
Partly re-enables dialog tests.
afshin Mar 25, 2019
816f0df
Re-enable all dialog tests except one that still fails.
afshin Mar 25, 2019
a230954
Add `readonly` functionality to polls.
afshin Mar 26, 2019
40c4444
Re-remove .travis.yml
afshin Mar 26, 2019
066ccdc
Remove artifacts from pre-InstanceTracker dialog tracking.
afshin Mar 26, 2019
4c43ea7
Make `interval`, `jitter`, `min`, and `max` (the polling frequency pa…
afshin Mar 27, 2019
f50dc72
Add `readonly` tests.
afshin Mar 27, 2019
88af585
Update `jitter` parameter to be a boolean | number and set its defaul…
afshin Mar 27, 2019
2f338d5
Update `jitter` semantics.
afshin Mar 27, 2019
f28f6de
this._setup => this._frequency
afshin Mar 28, 2019
9f8c0e1
Clean up refresh/start/stop semantics and implementation.
afshin Mar 28, 2019
987fc3e
Update docstrings.
afshin Mar 28, 2019
5e945ef
Audit private variables and methods.
afshin Mar 28, 2019
d71336b
Remove inaccurate docstrong.
afshin Mar 28, 2019
618a1bf
Use standby `when-hidden` logic.
afshin Mar 28, 2019
36ab861
Update poll tests.
afshin Mar 28, 2019
25eb20a
Check errors after normalizing in frequency function.
afshin Mar 28, 2019
866f497
Update Poll#dispose() test.
afshin Mar 28, 2019
5991335
Respect `readonly` flag in refresh/start/stop.
afshin Mar 28, 2019
c73770a
Clean up.
afshin Mar 28, 2019
2a56368
Fix client uses of Poll#refresh() to respect new semantics.
afshin Mar 29, 2019
c55b1e0
Fix refresh behavior and tests in services.
afshin Mar 29, 2019
9eeafb4
Add disposed phase.
afshin Mar 29, 2019
07383d7
Check if disposed by checking current phase.
afshin Mar 29, 2019
f03b410
Handle tick failures in public methods.
afshin Mar 29, 2019
8fa2de9
Remove concept of `readonly` and use a separate IPoll interface model…
afshin Mar 29, 2019
6b7d95e
Fix dangling promises.
afshin Mar 29, 2019
366285f
Add generic parameter defaults for IPoll.
afshin Mar 29, 2019
f41d8f6
Simplify poll frequency API.
afshin Apr 1, 2019
20912a6
Update disposed handling and check for disposed status in override.
afshin Apr 1, 2019
3235137
Define IPoll.Factory, make `execute` and `schedule` protected.
afshin Apr 1, 2019
f650bcc
Check that error exists before trying to print it in tests.
afshin Apr 1, 2019
63d5f3a
Clean up state initialization.
afshin Apr 1, 2019
d24d1f7
Update docstrings.
afshin Apr 1, 2019
5f7d216
Update handling of frequency and standby.
afshin Apr 2, 2019
ba3b1b4
IPoll.Standby => Poll.Standby
afshin Apr 2, 2019
d347a52
Use poll instead of setInterval CodeMirrEditor.
afshin Apr 2, 2019
e780d60
Update poll tests.
afshin Apr 2, 2019
11b9396
Clean up.
afshin Apr 2, 2019
2ad1e34
Polling should start as soon as `when` promise has resolved.
afshin Apr 2, 2019
5eaa49f
Poll#schedule() does not need to have the outstanding promise passed …
afshin Apr 3, 2019
ffe6b9f
Poll#_execute() does not need to have the outstanding promise passed …
afshin Apr 3, 2019
528c5ad
Add Poll#ready promise instead of checking manually in each method.
afshin Apr 3, 2019
731ff4b
Fix disposed logic regression.
afshin Apr 3, 2019
be58ebc
Update polling API, make `ready` protected. Update tests.
afshin Apr 5, 2019
8f4e7c6
Refactor `KernelManager` and its tests to pass.
afshin Apr 5, 2019
3e18400
Fix SessionManager and its tests.
afshin Apr 5, 2019
6e9bc50
Update TerminalManager.
afshin Apr 5, 2019
db18372
Clean up.
afshin Apr 5, 2019
890bc2f
Update the jitter to return a uniformly random value between base +- …
jasongrout Apr 3, 2019
c786303
Implement ‘decorrelated jitter’ as our backoff strategy.
jasongrout Apr 5, 2019
790a540
Clean up and fix tests.
afshin Apr 5, 2019
acd5002
Don't wait for pending promise to resolve before emitting ticked signal.
afshin Apr 6, 2019
52dc3d0
Address review suggestions.
afshin Apr 6, 2019
acfaa46
Update documentation to be more clear to me.
jasongrout Apr 6, 2019
dabe07e
IPoll.Tick => IPoll.State
afshin Apr 6, 2019
240876a
Add test to verify `tick` promise resolves after every `ticked` signa…
afshin Apr 8, 2019
5df0d05
Make Poll#tick test more robust.
afshin Apr 8, 2019
4bae4db
Clean up Poll#schedule() to make it easier to read and reason about.
afshin Apr 8, 2019
520ba66
Clean up some of the kernel manager async and request logic.
jasongrout Apr 8, 2019
28d55ba
Make session manager class consistent with the kernel manager changes.
jasongrout Apr 8, 2019
9751173
Merge pull request #24 from jasongrout/polling2
afshin Apr 8, 2019
4f80f73
Update terminal manager to be consistent with kernel/session manager …
jasongrout Apr 8, 2019
a8f58a6
Merge pull request #25 from jasongrout/polling3
afshin Apr 8, 2019
2f203d1
Revert session/terminal manager tests that now don’t change.
jasongrout Apr 8, 2019
b47481f
Update Poll#schedule docstring.
afshin Apr 9, 2019
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
361 changes: 194 additions & 167 deletions packages/apputils/src/dialog.ts

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions packages/codemirror/src/editor.ts
Expand Up @@ -15,6 +15,8 @@ import { Signal } from '@phosphor/signaling';

import { showDialog } from '@jupyterlab/apputils';

import { Poll } from '@jupyterlab/coreutils';

import { CodeEditor } from '@jupyterlab/codeeditor';

import { UUID } from '@phosphor/coreutils';
Expand Down Expand Up @@ -123,9 +125,16 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
this.clearHistory();
this._onMimeTypeChanged();
this._onCursorActivity();
this._timer = window.setInterval(() => {
this._checkSync();
}, 3000);
this._poll = new Poll({
factory: async () => {
this._checkSync();
},
frequency: { interval: 3000, backoff: false },
standby: () => {
// If changed, only stand by when hidden, otherwise always stand by.
return this._lastChange ? 'when-hidden' : true;
}
});

// Connect to changes.
model.value.changed.connect(
Expand Down Expand Up @@ -264,7 +273,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
this.host.removeEventListener('blur', this, true);
this.host.removeEventListener('scroll', this, true);
this._keydownHandlers.length = 0;
window.clearInterval(this._timer);
this._poll.dispose();
Signal.clearData(this);
}

Expand Down Expand Up @@ -1068,7 +1077,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
private _needsRefresh = false;
private _isDisposed = false;
private _lastChange: CodeMirror.EditorChange | null = null;
private _timer = -1;
private _poll: Poll;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/coreutils/src/index.ts
Expand Up @@ -8,6 +8,7 @@ export * from './markdowncodeblocks';
export * from './nbformat';
export * from './pageconfig';
export * from './path';
export * from './poll';
export * from './settingregistry';
export * from './statedb';
export * from './text';
Expand Down
2 changes: 1 addition & 1 deletion packages/coreutils/src/pageconfig.ts
Expand Up @@ -55,7 +55,7 @@ export namespace PageConfig {
let found = false;

// Use script tag if available.
if (typeof document !== 'undefined') {
if (typeof document !== 'undefined' && document) {
const el = document.getElementById('jupyter-config-data');

if (el) {
Expand Down