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

Better error handling when kernel crashes due to overridden built in modules #8237

Merged
merged 10 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"env": {
"VSC_JUPYTER_CI_TEST_GREP": "", // Leave as `VSCode Notebook` to run only Notebook tests.
"VSC_JUPYTER_CI_TEST_INVERT_GREP": "", // Initialize this to invert the grep (exclude tests with value defined in grep).
"CI_PYTHON_PATH": "/home/don/samples/pySamples/crap/.venv/bin/python", // Update with path to real python interpereter used for testing.
"CI_PYTHON_PATH": "", // Update with path to real python interpereter used for testing.
"VSC_FORCE_REAL_JUPYTER": "true", // Enalbe tests that require Jupyter.
"VSC_JUPYTER_CI_RUN_NON_PYTHON_NB_TEST": "", // Initialize this to run tests again Julia & other kernels.
"VSC_JUPYTER_RUN_NB_TEST": "true", // Initialize this to run notebook tests (must be using VSC Insiders).
Expand All @@ -209,7 +209,7 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/out/**/*.js", "!${workspaceFolder}/**/node_modules**/*"],
// "preLaunchTask": "Compile",
"preLaunchTask": "Compile",
"skipFiles": ["<node_internals>/**"],
"presentation": {
"group": "2_tests",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@
"DataScience.failedToInterruptKernel": "Failed to interrupt the Kernel.",
"DataScience.kernelDied": "The kernel died. View Jupyter [log](command:jupyter.viewOutput) for further details. \nError: {0}...",
"DataScience.kernelDiedWithoutError": "The kernel '{0}' died. View Jupyter [log](command:jupyter.viewOutput) for further details.",
"DataScience.fileSeemsToBeInterferingWithKernelStartup": "The file '{0}' seems to be overriding built in modules and interfering with the startup of the kernel. Consider renaming the file and starting the kernel again.",
"DataScience.cannotRunCellKernelIsDead": "Cannot run cells, as the kernel '{0}' is dead.",
"DataScience.waitingForJupyterSessionToBeIdle": "Waiting for Jupyter Session to be idle",
"DataScience.gettingListOfKernelsForLocalConnection": "Fetching Kernels",
Expand Down
7 changes: 0 additions & 7 deletions pythonFiles/vscode_datascience_helpers/kernel_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
# See comment at the point of our use of Popen
from subprocess import Popen, PIPE # nosec

from ipython_genutils.encoding import getdefaultencoding
from ipython_genutils.py3compat import cast_bytes_py2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer required, was only required for python 2.7
Also ipython_genutils is no longer shipping in conda



def launch_kernel(
cmd,
Expand Down Expand Up @@ -79,7 +76,6 @@ def launch_kernel(

env = env if (env is not None) else os.environ.copy()

encoding = getdefaultencoding(prefer_stream=False)
kwargs = kw.copy()
main_args = dict(
stdin=_stdin,
Expand All @@ -92,10 +88,7 @@ def launch_kernel(

# Spawn a kernel.
if sys.platform == "win32":
# Popen on Python 2 on Windows cannot handle unicode args or cwd
cmd = [cast_bytes_py2(c, encoding) for c in cmd]
if cwd:
cwd = cast_bytes_py2(cwd, sys.getfilesystemencoding() or "ascii")
kwargs["cwd"] = cwd

from .win_interrupt import create_interrupt_event
Expand Down
17 changes: 12 additions & 5 deletions src/client/common/cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ export class CancellationError extends BaseError {
* @param {({ defaultValue: T; token: CancellationToken; cancelAction: 'reject' | 'resolve' })} options
* @returns {Promise<T>}
*/
export function createPromiseFromCancellation<T>(options: {
defaultValue: T;
token?: CancellationToken;
cancelAction: 'reject' | 'resolve';
}): Promise<T> {
export function createPromiseFromCancellation<T>(
options:
| {
defaultValue: T;
token?: CancellationToken;
cancelAction: 'resolve';
}
| {
token?: CancellationToken;
cancelAction: 'reject';
}
): Promise<T> {
return new Promise<T>((resolve, reject) => {
// Never resolve.
if (!options.token) {
Expand Down
Loading