--- a/eric6/DebugClients/Python/QProcessExtension.py Mon Feb 10 19:49:45 2020 +0100 +++ b/eric6/DebugClients/Python/QProcessExtension.py Tue Feb 11 18:58:38 2020 +0100 @@ -10,19 +10,19 @@ import os -_startOptions = [] +_debugClient = None -def patchQProcess(module, startOptions): +def patchQProcess(module, debugClient): """ Function to patch the QtCore module's QProcess. @param module reference to the imported module to be patched @type module - @param startOptions reference to the saved start options - @type tuple + @param debugClient reference to the debug client object + @type DebugClient """ # __IGNORE_WARNING_D234__ - global _startOptions + global _debugClient class QProcessWrapper(module.QProcess): """ @@ -34,7 +34,7 @@ """ super(QProcessWrapper, self).__init__(parent) - def __modifyArgs(self, arguments): + def __modifyArgs(self, arguments, multiprocessSupport): """ Private method to modify the arguments given to the start method. @@ -44,12 +44,13 @@ @rtype list of str """ (wd, host, port, exceptions, tracePython, redirect, - noencoding) = _startOptions[:7] + noencoding) = _debugClient.startOptions[:7] + modifiedArguments = [ os.path.join(os.path.dirname(__file__), "DebugClient.py"), "-h", host, "-p", str(port), - "--no-passive" + "--no-passive", ] if wd: @@ -62,6 +63,8 @@ modifiedArguments.append("-n") if noencoding: modifiedArguments.append("--no-encoding") + if multiprocessSupport: + modifiedArguments.append("--multiprocess") modifiedArguments.append("--") # end the arguments for DebugClient modifiedArguments.extend(arguments) @@ -82,9 +85,11 @@ @type dict """ if ( - (len(args) >= 2 and isinstance(args[1], list)) or - (len(args) == 1 and not isinstance(args[0], str)) or - len(args) == 0 + _debugClient.debugging and + _debugClient.multiprocessSupport and + ((len(args) >= 2 and isinstance(args[1], list)) or + (len(args) == 1 and not isinstance(args[0], str)) or + len(args) == 0) ): # TODO: implement this if len(args) >= 2: @@ -101,14 +106,16 @@ mode = args[0] else: mode = module.QIODevice.ReadWrite - if "python" in program.lower(): + if "python" in program.lower() and arguments[0] != "-m": # assume a Python script is to be started - newArgs = self.__modifyArgs(arguments) + # '-m' option to python is not (yet) supported + newArgs = self.__modifyArgs( + arguments, _debugClient.multiprocessSupport) super(QProcessWrapper, self).start(program, newArgs, mode) else: super(QProcessWrapper, self).start(*args, **kwargs) else: super(QProcessWrapper, self).start(*args, **kwargs) - _startOptions = startOptions[:] + _debugClient = debugClient module.QProcess = QProcessWrapper