本文整理汇总了TypeScript中@jupyterlab/services.Session类的典型用法代码示例。如果您正苦于以下问题:TypeScript Session类的具体用法?TypeScript Session怎么用?TypeScript Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Session类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should fail for error response status', async () => {
const serverSettings = getRequestHandler(500, {});
const sessionModel = createSessionModel();
const options = createSessionOptions(sessionModel, serverSettings);
const sessionPromise = Session.startNew(options);
await expectFailure(sessionPromise, '');
});
示例2: it
it('should be safe to call twice', () => {
const session = Session.connectTo(defaultSession.model);
session.dispose();
expect(session.isDisposed).to.equal(true);
session.dispose();
expect(session.isDisposed).to.equal(true);
});
示例3: main
function main() {
// Start a new session.
let options: Session.IOptions = {
kernelName: 'python',
path: 'foo.ipynb'
};
let session: Session.ISession;
log('Starting session');
Session.startNew(options).then(s => {
log('Session started');
session = s;
// Rename the session.
return session.setPath('bar.ipynb');
}).then(() => {
log(`Session renamed to ${session.path}`);
// Execute and handle replies on the kernel.
let future = session.kernel.requestExecute({ code: 'a = 1' });
future.onReply = (reply) => {
log('Got execute reply');
};
return future.done;
}).then(() => {
log('Future is fulfilled');
// Shut down the session.
return session.shutdown();
}).then(() => {
log('Session shut down');
log('Test Complete!');
}).catch(err => {
console.error(err);
log('Test Failed! See the console output for details');
});
}
示例4: main
function main(): void {
let path = 'dummy_path';
let query: { [key: string]: string } = Object.create(null);
window.location.search.substr(1).split('&').forEach(item => {
let pair = item.split('=');
if (pair[0]) {
query[pair[0]] = pair[1];
}
});
if (!query['path']) {
Session.startNew({ path }).then(session => { startApp(session); });
return;
}
Session.findByPath(query['path'])
.then(model => { return Session.connectTo(model.id); })
.then(session => { startApp(session); })
.catch(error => {
console.warn(`path="${query['path']}"`, error);
Session.startNew({ path }).then(session => { startApp(session); });
});
}