From af2f86eed5e484ce4ed8b7f55bc8d4ffe36cbcd9 Mon Sep 17 00:00:00 2001 From: Pavel Minaev Date: Fri, 2 Nov 2018 12:36:21 -0700 Subject: [PATCH] Fix #984: Remote debugging not working with multiproc Use parent's --host when spawning child processes. --- ptvsd/__main__.py | 8 ++++---- ptvsd/multiproc.py | 2 +- ptvsd/options.py | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ptvsd/__main__.py b/ptvsd/__main__.py index 8c75f528..d31cc862 100644 --- a/ptvsd/__main__.py +++ b/ptvsd/__main__.py @@ -216,10 +216,10 @@ def _parse_args(prog, argv): args = parser.parse_args(argv) ns = vars(args) - host = ns.pop('host', None) - port = ns.pop('port') - client = ns.pop('client') - args.address = (Address.as_client if client else Address.as_server)(host, port) # noqa + options.host = ns.pop('host', None) + options.port = ns.pop('port') + options.client = ns.pop('client') + args.address = (Address.as_client if options.client else Address.as_server)(options.host, options.port) # noqa if ns['multiprocess']: options.multiprocess = True diff --git a/ptvsd/multiproc.py b/ptvsd/multiproc.py index 34eab550..28a0909c 100644 --- a/ptvsd/multiproc.py +++ b/ptvsd/multiproc.py @@ -243,7 +243,7 @@ def patch_args(args): from ptvsd import __main__ args[i:i] = [ __main__.__file__, - '--host', 'localhost', + '--host', options.host, '--port', '0', '--wait', '--multiprocess', diff --git a/ptvsd/options.py b/ptvsd/options.py index b7c5ff90..beade98e 100644 --- a/ptvsd/options.py +++ b/ptvsd/options.py @@ -8,23 +8,37 @@ from __future__ import print_function, with_statement, absolute_import """ptvsd command-line options that need to be globally available. """ +client = None +"""If True, this instance of ptvsd is operating in client mode - i.e. it connects +to the IDE, instead of waiting for an incoming connection from the IDE. +""" + +host = None +"""Name or IP address of the network interface used by ptvsd. If runing in server +mode, this is the interface on which it listens for incoming connections. If running +in client mode, this is the interface to which it connects. +""" + +port = None +"""Port number used by ptvsd. If running in server mode, this is the port on which it +listens for incoming connections. If running in client mode, this is port to which it +connects. +""" + code = None """When running with -c, specifies the code that needs to be run. """ - multiprocess = False """Whether this ptvsd instance is running in multiprocess mode, detouring creation of new processes and enabling debugging for them. """ - subprocess_of = None """If not None, the process ID of the parent process (running in multiprocess mode) that spawned this subprocess. """ - subprocess_notify = None """The port number of the subprocess listener. If specified, a 'ptvsd_subprocess' notification must be sent to that port once this ptvsd is initialized and ready to