Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._isReady = true;
});
// Start model and specs polling with exponential backoff.
this._pollModels = new Poll({
auto: false,
factory: () => this.requestRunning(),
frequency: {
interval: 10 * 1000,
backoff: true,
max: 300 * 1000
},
name: `@jupyterlab/services:SessionManager#models`,
standby: options.standby || 'when-hidden'
});
this._pollSpecs = new Poll({
auto: false,
factory: () => this.requestSpecs(),
frequency: {
interval: 61 * 1000,
backoff: true,
max: 300 * 1000
},
name: `@jupyterlab/services:SessionManager#specs`,
standby: options.standby || 'when-hidden'
});
void this.ready.then(() => {
void this._pollModels.start();
void this._pollSpecs.start();
});
}
this.serverSettings =
options.serverSettings || ServerConnection.makeSettings();
// Initialize internal data.
this._ready = Promise.all([this.requestRunning(), this.requestSpecs()])
.then(_ => undefined)
.catch(_ => undefined)
.then(() => {
if (this.isDisposed) {
return;
}
this._isReady = true;
});
// Start model and specs polling with exponential backoff.
this._pollModels = new Poll({
auto: false,
factory: () => this.requestRunning(),
frequency: {
interval: 10 * 1000,
backoff: true,
max: 300 * 1000
},
name: `@jupyterlab/services:KernelManager#models`,
standby: options.standby || 'when-hidden'
});
this._pollSpecs = new Poll({
auto: false,
factory: () => this.requestSpecs(),
frequency: {
interval: 61 * 1000,
backoff: true,
return;
}
// Initialize internal data then start polling.
this._ready = this.requestRunning()
.then(_ => undefined)
.catch(_ => undefined)
.then(() => {
if (this.isDisposed) {
return;
}
this._isReady = true;
});
// Start polling with exponential backoff.
this._pollModels = new Poll({
auto: false,
factory: () => this.requestRunning(),
frequency: {
interval: 10 * 1000,
backoff: true,
max: 300 * 1000
},
name: `@jupyterlab/services:TerminalManager#models`,
standby: options.standby || 'when-hidden'
});
void this.ready.then(() => {
void this._pollModels.start();
});
}
this.serverSettings =
options.serverSettings || ServerConnection.makeSettings();
// Initialize internal data.
this._ready = Promise.all([this.requestRunning(), this.requestSpecs()])
.then(_ => undefined)
.catch(_ => undefined)
.then(() => {
if (this.isDisposed) {
return;
}
this._isReady = true;
});
// Start model and specs polling with exponential backoff.
this._pollModels = new Poll({
auto: false,
factory: () => this.requestRunning(),
frequency: {
interval: 10 * 1000,
backoff: true,
max: 300 * 1000
},
name: `@jupyterlab/services:SessionManager#models`,
standby: options.standby || 'when-hidden'
});
this._pollSpecs = new Poll({
auto: false,
factory: () => this.requestSpecs(),
frequency: {
interval: 61 * 1000,
backoff: true,
private _startUrlCheckTimer(): void {
this._poll = new Poll({
factory: async () => {
const url = this._url;
// Don't bother checking if there is no url.
if (!url) {
return;
}
const result = await Private.testDaskDashboard(
url,
this._serverSettings
);
// No change.
if (result === this._isValid) {
return;
}
// Show an error if the connection died.
if (!result && this._isValid) {
it('should emit when the poll is disposed', () => {
poll = new Poll({
factory: () => Promise.resolve(),
name: '@jupyterlab/test-coreutils:Poll#disposed-1'
});
let disposed = false;
poll.disposed.connect(() => {
disposed = true;
});
poll.dispose();
expect(disposed).to.equal(true);
});
});
it('should indicate whether the poll is disposed', () => {
poll = new Poll({
factory: () => Promise.resolve(),
name: '@jupyterlab/test-coreutils:Poll#isDisposed-1'
});
expect(poll.isDisposed).to.equal(false);
poll.dispose();
expect(poll.isDisposed).to.equal(true);
});
});
it('should dispose the poll and be safe to call repeatedly', async () => {
let rejected = false;
let tick: Promise;
poll = new Poll({
name: '@jupyterlab/test-coreutils:Poll#dispose()-1',
factory: () => Promise.resolve()
});
tick = poll.tick;
expect(poll.isDisposed).to.equal(false);
poll.dispose();
expect(poll.isDisposed).to.equal(true);
try {
await tick;
} catch (error) {
rejected = true;
}
poll.dispose();
expect(rejected).to.equal(true);
});
});
);
services.sessions.runningChanged.connect(
this._onRunningChanged,
this
);
this._unloadEventListener = (e: Event) => {
if (this._uploads.length > 0) {
const confirmationMessage = 'Files still uploading';
(e as any).returnValue = confirmationMessage;
return confirmationMessage;
}
};
window.addEventListener('beforeunload', this._unloadEventListener);
this._poll = new Poll({
factory: () => this.cd('.'),
frequency: {
interval: refreshInterval,
backoff: true,
max: 300 * 1000
},
standby: 'when-hidden'
});
}
const refreshInterval = options.refreshInterval || DEFAULT_REFRESH_INTERVAL;
const { services } = options.manager;
services.contents.fileChanged.connect(this._onFileChanged, this);
services.sessions.runningChanged.connect(this._onRunningChanged, this);
this._unloadEventListener = (e: Event) => {
if (this._uploads.length > 0) {
const confirmationMessage = 'Files still uploading';
(e as any).returnValue = confirmationMessage;
return confirmationMessage;
}
};
window.addEventListener('beforeunload', this._unloadEventListener);
this._poll = new Poll({
factory: () => this.cd('.'),
frequency: {
interval: refreshInterval,
backoff: true,
max: 300 * 1000
},
standby: 'when-hidden'
});
}