-
Notifications
You must be signed in to change notification settings - Fork 299
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
prevent debugpy from getting stuck #7612
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f827552
-prevent debugpy from getting stuck
014082d
undo debug cell button changes
737cb03
-remove throttle
2b4d0bc
simplify into a function
c780500
return if notebook is in process of starting
147ef55
oops
42a0e79
Check if its already debugging
d55d4e9
imrpove readability
e1cb175
fix context keys in case session is going,
52fcf32
change context keys after awaiting the debugger to
9889241
more context key management
7096f8c
remove isDebugging conditions
ed8b70a
fix failing test
eb19626
wait more
58237c8
try to fix tests
8c53b34
tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ import { | |
ProgressLocation, | ||
DebugAdapterDescriptor, | ||
Event, | ||
EventEmitter | ||
EventEmitter, | ||
NotebookEditor | ||
} from 'vscode'; | ||
import * as path from 'path'; | ||
import { IKernel, IKernelProvider } from '../../datascience/jupyter/kernels/types'; | ||
|
@@ -51,6 +52,7 @@ export class DebuggingManager implements IExtensionSingleActivationService, IDeb | |
private notebookToDebugger = new Map<NotebookDocument, Debugger>(); | ||
private notebookToDebugAdapter = new Map<NotebookDocument, KernelDebugAdapter>(); | ||
private notebookToRunByLineController = new Map<NotebookDocument, RunByLineController>(); | ||
private notebookInProgress = new Set<NotebookDocument>(); | ||
private cache = new Map<PythonEnvironment, boolean>(); | ||
private readonly disposables: IDisposable[] = []; | ||
private _doneDebugging = new EventEmitter<void>(); | ||
|
@@ -94,19 +96,7 @@ export class DebuggingManager implements IExtensionSingleActivationService, IDeb | |
|
||
this.commandManager.registerCommand(DSCommands.DebugNotebook, async () => { | ||
const editor = this.vscNotebook.activeNotebookEditor; | ||
if (editor) { | ||
if (this.notebookToDebugger.has(editor.document)) { | ||
return; | ||
} | ||
if (await this.checkForIpykernel6(editor.document)) { | ||
this.updateToolbar(true); | ||
void this.startDebugging(editor.document); | ||
} else { | ||
void this.installIpykernel6(); | ||
} | ||
} else { | ||
void this.appShell.showErrorMessage(DataScience.noNotebookToDebug()); | ||
} | ||
await this.tryToStartDebugging(KernelDebugMode.Everything, editor); | ||
}), | ||
|
||
this.commandManager.registerCommand(DSCommands.RunByLine, async (cell: NotebookCell | undefined) => { | ||
|
@@ -123,20 +113,7 @@ export class DebuggingManager implements IExtensionSingleActivationService, IDeb | |
return; | ||
} | ||
|
||
if (editor) { | ||
if (this.notebookToDebugger.has(editor.document)) { | ||
return; | ||
} | ||
if (await this.checkForIpykernel6(editor.document, DataScience.startingRunByLine())) { | ||
this.updateToolbar(true); | ||
this.updateCellToolbar(true); | ||
await this.startDebuggingCell(editor.document, KernelDebugMode.RunByLine, cell); | ||
} else { | ||
void this.installIpykernel6(); | ||
} | ||
} else { | ||
void this.appShell.showErrorMessage(DataScience.noNotebookToDebug()); | ||
} | ||
await this.tryToStartDebugging(KernelDebugMode.RunByLine, editor, cell); | ||
}), | ||
|
||
this.commandManager.registerCommand(DSCommands.RunByLineNext, (cell: NotebookCell | undefined) => { | ||
|
@@ -185,19 +162,7 @@ export class DebuggingManager implements IExtensionSingleActivationService, IDeb | |
return; | ||
} | ||
|
||
if (editor) { | ||
if (this.notebookToDebugger.has(editor.document)) { | ||
return; | ||
} | ||
if (await this.checkForIpykernel6(editor.document)) { | ||
this.updateToolbar(true); | ||
void this.startDebuggingCell(editor.document, KernelDebugMode.Cell, cell); | ||
} else { | ||
void this.installIpykernel6(); | ||
} | ||
} else { | ||
void this.appShell.showErrorMessage(DataScience.noNotebookToDebug()); | ||
} | ||
await this.tryToStartDebugging(KernelDebugMode.Cell, editor, cell); | ||
}) | ||
); | ||
} | ||
|
@@ -243,6 +208,50 @@ export class DebuggingManager implements IExtensionSingleActivationService, IDeb | |
this.runByLineInProgress.set(runningByLine).ignoreErrors(); | ||
} | ||
|
||
private async tryToStartDebugging(mode: KernelDebugMode, editor?: NotebookEditor, cell?: NotebookCell) { | ||
if (editor) { | ||
if (this.notebookInProgress.has(editor.document)) { | ||
return; | ||
} | ||
|
||
try { | ||
this.notebookInProgress.add(editor.document); | ||
if ( | ||
await this.checkForIpykernel6( | ||
editor.document, | ||
mode === KernelDebugMode.RunByLine ? DataScience.startingRunByLine() : undefined | ||
) | ||
) { | ||
switch (mode) { | ||
case KernelDebugMode.Everything: | ||
this.updateToolbar(true); | ||
void this.startDebugging(editor.document); | ||
break; | ||
case KernelDebugMode.Cell: | ||
if (cell) { | ||
this.updateToolbar(true); | ||
void this.startDebuggingCell(editor.document, KernelDebugMode.Cell, cell); | ||
} | ||
break; | ||
case KernelDebugMode.RunByLine: | ||
if (cell) { | ||
this.updateToolbar(true); | ||
this.updateCellToolbar(true); | ||
await this.startDebuggingCell(editor.document, KernelDebugMode.RunByLine, cell); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in line 233 we're not awaiting, but here we're awaiting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'll be good to await them all |
||
} | ||
break; | ||
} | ||
} else { | ||
void this.installIpykernel6(); | ||
} | ||
} finally { | ||
this.notebookInProgress.delete(editor.document); | ||
} | ||
} else { | ||
void this.appShell.showErrorMessage(DataScience.noNotebookToDebug()); | ||
} | ||
} | ||
|
||
private async startDebuggingCell( | ||
doc: NotebookDocument, | ||
mode: KernelDebugMode.Cell | KernelDebugMode.RunByLine, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is checking the case where debugging is starting, but doesn't it still need to check
this.notebookToDebugger.has
?