Skip to content

Commit b741e1a

Browse files
change to operate in non-test cases (#5515)
1 parent 871a304 commit b741e1a

13 files changed

Lines changed: 22 additions & 4 deletions

File tree

news/3 Code Health/5430.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Increase timeout and retries in Jupyter wait for idle

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,12 @@
11491149
"description": "Amount of time (in ms) to wait for the Jupyter Notebook server to start.",
11501150
"scope": "resource"
11511151
},
1152+
"python.dataScience.jupyterLaunchRetries": {
1153+
"type": "number",
1154+
"default": 3,
1155+
"description": "Number of times to attempt to connect to the Jupyter Notebook",
1156+
"scope": "resource"
1157+
},
11521158
"python.dataScience.jupyterServerURI": {
11531159
"type": "string",
11541160
"default": "local",

src/client/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ export interface IDataScienceSettings {
287287
enabled: boolean;
288288
jupyterInterruptTimeout: number;
289289
jupyterLaunchTimeout: number;
290+
jupyterLaunchRetries: number;
290291
jupyterServerURI: string;
291292
notebookFileRoot: string;
292293
changeDirOnImportExport: boolean;

src/client/datascience/jupyter/jupyterExecution.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ export class JupyterExecutionBase implements IJupyterExecution {
135135
traceInfo(`Connecting to ${options ? options.purpose : 'unknown type of'} server`);
136136
const interpreter = await this.interpreterService.getActiveInterpreter();
137137

138-
// Try to connect to our jupyter process. Give it at most 2 tries.
138+
// Try to connect to our jupyter process. Check our setting for the number of tries
139139
let tryCount = 0;
140-
while (tryCount < 2) {
140+
const maxTries = this.configuration.getSettings().datascience.jupyterLaunchRetries;
141+
while (tryCount < maxTries) {
141142
try {
142143
// Start or connect to the process
143144
startInfo = await this.startOrConnect(options, cancelToken);
@@ -167,7 +168,7 @@ export class JupyterExecutionBase implements IJupyterExecution {
167168
traceInfo('Killing server because of error');
168169
await result.dispose();
169170
}
170-
if (err instanceof JupyterWaitForIdleError && tryCount < 2) {
171+
if (err instanceof JupyterWaitForIdleError && tryCount < maxTries) {
171172
// Special case. This sometimes happens where jupyter doesn't ever connect. Cleanup after
172173
// ourselves and propagate the failure outwards.
173174
traceInfo('Retry because of wait for idle problem.');

src/client/datascience/jupyter/jupyterServer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ export class JupyterServerBase implements INotebookServer {
173173

174174
// Wait for it to be ready
175175
traceInfo(`Waiting for idle ${this.id}`);
176-
await this.session.waitForIdle(Number.MAX_SAFE_INTEGER);
176+
const idleTimeout = this.configService.getSettings().datascience.jupyterLaunchTimeout;
177+
await this.session.waitForIdle(idleTimeout);
177178

178179
traceInfo(`Performing initial setup ${this.id}`);
179180
// Run our initial setup and plot magics

src/datascience-ui/react-common/settingsReactSide.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function load() {
3434
loadedSettings = {
3535
allowImportFromNotebook: true,
3636
jupyterLaunchTimeout: 10,
37+
jupyterLaunchRetries: 3,
3738
enabled: true,
3839
jupyterServerURI: 'local',
3940
notebookFileRoot: 'WORKSPACE',

src/test/datascience/color.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ suite('Theme colors', () => {
5151
settings.datascience = {
5252
allowImportFromNotebook: true,
5353
jupyterLaunchTimeout: 20000,
54+
jupyterLaunchRetries: 3,
5455
enabled: true,
5556
jupyterServerURI: 'local',
5657
notebookFileRoot: 'WORKSPACE',

src/test/datascience/dataScienceIocContainer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ export class DataScienceIocContainer extends UnitTestIocContainer {
308308
this.pythonSettings.datascience = {
309309
allowImportFromNotebook: true,
310310
jupyterLaunchTimeout: 20000,
311+
jupyterLaunchRetries: 3,
311312
enabled: true,
312313
jupyterServerURI: 'local',
313314
notebookFileRoot: 'WORKSPACE',

src/test/datascience/editor-integration/codewatcher.unit.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ suite('DataScience Code Watcher Unit Tests', () => {
5454
pythonSettings.datascience = {
5555
allowImportFromNotebook: true,
5656
jupyterLaunchTimeout: 20000,
57+
jupyterLaunchRetries: 3,
5758
enabled: true,
5859
jupyterServerURI: 'local',
5960
notebookFileRoot: 'WORKSPACE',

src/test/datascience/execution.unit.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ suite('Jupyter Execution', async () => {
521521
pythonSettings.datascience = {
522522
allowImportFromNotebook: true,
523523
jupyterLaunchTimeout: 10,
524+
jupyterLaunchRetries: 3,
524525
enabled: true,
525526
jupyterServerURI: 'local',
526527
notebookFileRoot: 'WORKSPACE',

0 commit comments

Comments
 (0)