diff --git a/ptvsd/_vendored/__init__.py b/ptvsd/_vendored/__init__.py index 0d9a3262e..f963e11a6 100644 --- a/ptvsd/_vendored/__init__.py +++ b/ptvsd/_vendored/__init__.py @@ -113,7 +113,6 @@ def vendored(project, root=None): try: yield root finally: - #del sys.path[0] sys.path.remove(root) diff --git a/ptvsd/_vendored/force_pydevd.py b/ptvsd/_vendored/force_pydevd.py index 3a1f19692..a4f3371da 100644 --- a/ptvsd/_vendored/force_pydevd.py +++ b/ptvsd/_vendored/force_pydevd.py @@ -1,6 +1,7 @@ +from importlib import import_module import warnings -from . import check_modules, prefix_matcher, preimport +from . import check_modules, prefix_matcher, preimport, vendored # Ensure that pydevd is our vendored copy. @@ -13,6 +14,16 @@ warnings.warn(msg + ':\n {}'.format('\n '.join(_unvendored))) +# Constants must be set before importing any other pydevd module +# # due to heavy use of "from" in them. +with vendored('pydevd'): + pydevd_constants = import_module('_pydevd_bundle.pydevd_constants') +# Disable this, since we aren't packaging the Cython modules at the moment. +pydevd_constants.CYTHON_SUPPORTED = False +# We limit representation size in our representation provider when needed. +pydevd_constants.MAXIMUM_VARIABLE_REPRESENTATION_SIZE = 2**32 + + # Now make sure all the top-level modules and packages in pydevd are # loaded. Any pydevd modules that aren't loaded at this point, will # be loaded using their parent package's __path__ (i.e. one of the diff --git a/ptvsd/wrapper.py b/ptvsd/wrapper.py index 50df2589d..696e38421 100644 --- a/ptvsd/wrapper.py +++ b/ptvsd/wrapper.py @@ -27,12 +27,6 @@ import warnings from xml.sax import SAXParseException -import _pydevd_bundle.pydevd_constants as pydevd_constants -# Disable this, since we aren't packaging the Cython modules at the moment. -pydevd_constants.CYTHON_SUPPORTED = False -# We limit representation size in our representation provider when needed. -pydevd_constants.MAXIMUM_VARIABLE_REPRESENTATION_SIZE = 2**32 - import _pydevd_bundle.pydevd_comm as pydevd_comm # noqa import _pydevd_bundle.pydevd_extension_api as pydevd_extapi # noqa import _pydevd_bundle.pydevd_extension_utils as pydevd_extutil # noqa @@ -67,6 +61,7 @@ supportsSetExpression=True, supportsModulesRequest=True, supportsLogPoints=True, + supportTerminateDebuggee=True, exceptionBreakpointFilters=[ { 'filter': 'raised', @@ -853,7 +848,9 @@ def _handle_disconnect(self, request): self.disconnect_request_event.set() self._notify_disconnecting(not self._closed) if not self._closed: - self.close() + # Closing the socket causes pydevd to resume all threads, + # so just terminate the process altogether. + sys.exit(0) def _wait_for_server_thread(self): if self.server_thread is None: