Fixed a few issues with the new multi process debugger.

Sun, 20 Dec 2020 20:13:42 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 20 Dec 2020 20:13:42 +0100
changeset 7903
827d89937c30
parent 7902
a5248d27c8a9
child 7904
0424ebe2d3b1

Fixed a few issues with the new multi process debugger.

eric6/APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/MultiprocessingExtension.py file | annotate | diff | comparison | revisions
eric6/Debugger/DebugUI.py file | annotate | diff | comparison | revisions
eric6/Debugger/DebugViewer.py file | annotate | diff | comparison | revisions
eric6/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
eric6/Documentation/Source/eric6.DebugClients.Python.DebugBase.html file | annotate | diff | comparison | revisions
eric6/Documentation/Source/eric6.DebugClients.Python.DebugClientBase.html file | annotate | diff | comparison | revisions
eric6/Documentation/Source/eric6.Preferences.__init__.html file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
--- a/eric6/APIs/Python3/eric6.api	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/APIs/Python3/eric6.api	Sun Dec 20 20:13:42 2020 +0100
@@ -265,7 +265,7 @@
 eric6.DebugClients.Python.DebugBase.DebugBase.pollTimerEnabled?7
 eric6.DebugClients.Python.DebugBase.DebugBase.profile?4(frame, event, arg)
 eric6.DebugClients.Python.DebugBase.DebugBase.profileWithRecursion?4(frame, event, arg)
-eric6.DebugClients.Python.DebugBase.DebugBase.run?4(cmd, globalsDict=None, localsDict=None, debug=True)
+eric6.DebugClients.Python.DebugBase.DebugBase.run?4(cmd, globalsDict=None, localsDict=None, debug=True, closeSession=True)
 eric6.DebugClients.Python.DebugBase.DebugBase.setRecursionDepth?4(frame)
 eric6.DebugClients.Python.DebugBase.DebugBase.set_continue?4(special)
 eric6.DebugClients.Python.DebugBase.DebugBase.set_next?4(frame)
@@ -301,7 +301,7 @@
 eric6.DebugClients.Python.DebugClientBase.DebugClientBase.handleJsonCommand?4(jsonStr)
 eric6.DebugClients.Python.DebugClientBase.DebugClientBase.input?4(prompt, echo=True)
 eric6.DebugClients.Python.DebugClientBase.DebugClientBase.main?4()
-eric6.DebugClients.Python.DebugClientBase.DebugClientBase.progTerminated?4(status, message="")
+eric6.DebugClients.Python.DebugClientBase.DebugClientBase.progTerminated?4(status, message="", closeSession=True)
 eric6.DebugClients.Python.DebugClientBase.DebugClientBase.readReady?4(stream)
 eric6.DebugClients.Python.DebugClientBase.DebugClientBase.run_call?4(scriptname, func, *args)
 eric6.DebugClients.Python.DebugClientBase.DebugClientBase.sendCallTrace?4(event, fromInfo, toInfo)
--- a/eric6/DebugClients/Python/DebugBase.py	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/DebugClients/Python/DebugBase.py	Sun Dec 20 20:13:42 2020 +0100
@@ -449,7 +449,8 @@
             sys.settrace(None)
             sys.setprofile(None)
     
-    def run(self, cmd, globalsDict=None, localsDict=None, debug=True):
+    def run(self, cmd, globalsDict=None, localsDict=None, debug=True,
+            closeSession=True):
         """
         Public method to start a given command under debugger control.
         
@@ -463,6 +464,9 @@
         @type bool
         @return exit code of the program
         @rtype int
+        @param closeSession flag indicating to close the debugger session
+            at exit
+        @type bool
         """
         if globalsDict is None:
             import __main__
@@ -484,13 +488,14 @@
         try:
             exec(cmd, globalsDict, localsDict)      # secok
             atexit._run_exitfuncs()
-            self._dbgClient.progTerminated(0)
+            self._dbgClient.progTerminated(0, closeSession=closeSession)
             exitcode = 0
         except SystemExit:
             atexit._run_exitfuncs()
             excinfo = sys.exc_info()
             exitcode, message = self.__extractSystemExitMessage(excinfo)
-            self._dbgClient.progTerminated(exitcode, message)
+            self._dbgClient.progTerminated(exitcode, message=message,
+                                           closeSession=closeSession)
         except Exception:
             excinfo = sys.exc_info()
             self.user_exception(excinfo, True)
--- a/eric6/DebugClients/Python/DebugClientBase.py	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Sun Dec 20 20:13:42 2020 +0100
@@ -20,7 +20,7 @@
 import signal
 import time
 import types
-import importlib
+import importlib.util
 import fnmatch
 
 
@@ -480,7 +480,8 @@
             res = 0
             code = self.__compileFileSource(self.running)
             if code:
-                self.mainThread.run(code, self.debugMod.__dict__, debug=False)
+                self.mainThread.run(code, self.debugMod.__dict__, debug=False,
+                                    closeSession=False)
 
         elif method == "RequestCoverage":
             from coverage import Coverage
@@ -514,7 +515,8 @@
             if code:
                 self.running = sys.argv[0]
                 self.cover.start()
-                self.mainThread.run(code, self.debugMod.__dict__, debug=False)
+                self.mainThread.run(code, self.debugMod.__dict__, debug=False,
+                                    closeSession=False)
                 self.cover.stop()
                 self.cover.save()
         
@@ -564,7 +566,7 @@
                     self.__unhandled_exception(*excinfo)
                 
                 self.prof.save()
-                self.progTerminated(res)
+                self.progTerminated(res, closeSession=False)
         
         elif method == "ExecuteStatement":
             if self.buffer:
@@ -823,14 +825,10 @@
         elif method == "RequestUTPrepare":
             if params["syspath"]:
                 sys.path = params["syspath"] + sys.path
-            sys.path.insert(
-                0, os.path.dirname(os.path.abspath(params["filename"])))
             top_level_dir = None
             if params["workdir"]:
                 os.chdir(params["workdir"])
                 top_level_dir = params["workdir"]
-            else:
-                os.chdir(sys.path[0])
             
             # set the system exception handling function to ensure, that
             # we report on all unhandled exceptions
@@ -844,6 +842,8 @@
                     discoveryStart = params["discoverystart"]
                     if not discoveryStart:
                         discoveryStart = params["workdir"]
+                    sys.path.insert(
+                        0, os.path.abspath(discoveryStart))
                     if params["testcases"]:
                         self.test = testLoader.loadTestsFromNames(
                             params["testcases"])
@@ -851,6 +851,10 @@
                         self.test = testLoader.discover(
                             discoveryStart, top_level_dir=top_level_dir)
                 else:
+                    sys.path.insert(
+                        0,
+                        os.path.dirname(os.path.abspath(params["filename"]))
+                    )
                     if params["filename"]:
                         spec = importlib.util.spec_from_file_location(
                             params["testname"], params["filename"])
@@ -913,7 +917,7 @@
                 sys.setprofile(None)
                 self.mainThread.run(
                     "result = self.test.run(self.testResult)\n",
-                    localsDict=locals_)
+                    localsDict=locals_, closeSession=False)
                 result = locals_["result"]
             else:
                 result = self.test.run(self.testResult)
@@ -1420,7 +1424,7 @@
         """
         return self.running
 
-    def progTerminated(self, status, message=""):
+    def progTerminated(self, status, message="", closeSession=True):
         """
         Public method to tell the debugger that the program has terminated.
         
@@ -1428,6 +1432,8 @@
         @type int
         @param message status message
         @type str
+        @param closeSession flag indicating to close the debugger session
+        @type bool
         """
         if status is None:
             status = 0
@@ -1450,7 +1456,8 @@
         # reset coding
         self.__coding = self.defaultCoding
         
-        self.sessionClose(False)
+        if closeSession:
+            self.sessionClose(False)
 
     def __dumpVariables(self, frmnr, scope, filterList):
         """
@@ -2105,7 +2112,6 @@
         self.passive = passive
         if passive:
             self.sendPassiveStartup(self.running, exceptions)
-        self.__interact()
         
         self.attachThread(mainThread=True)
         self.mainThread.tracePythonLibs(tracePython)
@@ -2152,7 +2158,7 @@
         """
         self.startDebugger(scriptname, enableTrace=False)
         res = self.mainThread.runcall(func, *args)
-        self.progTerminated(res)
+        self.progTerminated(res, closeSession=False)
         return res
     
     def __resolveHost(self, host):
--- a/eric6/DebugClients/Python/MultiprocessingExtension.py	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/DebugClients/Python/MultiprocessingExtension.py	Sun Dec 20 20:13:42 2020 +0100
@@ -67,9 +67,10 @@
                             multiprocessSupport=True
                         )
                     except Exception:
-                        print("Exception during multiprocessing bootstrap"
-                              " init:")
-                        # __IGNORE_WARNING_M801__
+                        print(
+                            # __IGNORE_WARNING_M801__
+                            "Exception during multiprocessing bootstrap init:"
+                        )
                         traceback.print_exc(file=sys.stdout)
                         sys.stdout.flush()
                         raise
--- a/eric6/Debugger/DebugUI.py	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/Debugger/DebugUI.py	Sun Dec 20 20:13:42 2020 +0100
@@ -1092,8 +1092,7 @@
                         self.ui, Program,
                         self.tr('<p><b>{0}</b> has terminated with an exit'
                                 ' status of {1}.</p>{2}').format(
-                            os.path.abspath(self.ui.currentProg),
-                            status, info)
+                            os.path.abspath(program), status, info)
                     )
             else:
                 if message:
@@ -1124,8 +1123,7 @@
                         self.appendStdout.emit(self.tr(
                             '"{0}" has terminated with an exit status of'
                             ' {1}.\n{2}\n').format(
-                            os.path.abspath(self.ui.currentProg),
-                            status, info)
+                            os.path.abspath(program), status, info)
                         )
     
     def __lastClientExited(self):
--- a/eric6/Debugger/DebugViewer.py	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/Debugger/DebugViewer.py	Sun Dec 20 20:13:42 2020 +0100
@@ -747,9 +747,11 @@
         @type str
         """
         itm = QTreeWidgetItem(self.__debuggersList, [debuggerId])
-        self.debugUI.showNotification(
-            self.tr("<p>Debugger with ID <b>{0}</b> has been connected.</p>")
-            .format(debuggerId))
+        if self.__debuggersList.topLevelItemCount() > 1:
+            self.debugUI.showNotification(
+                self.tr("<p>Debugger with ID <b>{0}</b> has been connected."
+                        "</p>")
+                .format(debuggerId))
         
         self.__debuggersList.header().resizeSections(
             QHeaderView.ResizeToContents)
Binary file eric6/Documentation/Help/source.qch has changed
--- a/eric6/Documentation/Source/eric6.DebugClients.Python.DebugBase.html	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/Documentation/Source/eric6.DebugClients.Python.DebugBase.html	Sun Dec 20 20:13:42 2020 +0100
@@ -737,7 +737,7 @@
 </dl>
 <a NAME="DebugBase.run" ID="DebugBase.run"></a>
 <h4>DebugBase.run</h4>
-<b>run</b>(<i>cmd, globalsDict=None, localsDict=None, debug=True</i>)
+<b>run</b>(<i>cmd, globalsDict=None, localsDict=None, debug=True, closeSession=True</i>)
 
 <p>
         Public method to start a given command under debugger control.
@@ -760,6 +760,11 @@
 <dd>
 flag if command should run under debugger control
 </dd>
+<dt><i>closeSession</i> (bool)</dt>
+<dd>
+flag indicating to close the debugger session
+            at exit
+</dd>
 </dl>
 <dl>
 <dt>Returns:</dt>
--- a/eric6/Documentation/Source/eric6.DebugClients.Python.DebugClientBase.html	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/Documentation/Source/eric6.DebugClients.Python.DebugClientBase.html	Sun Dec 20 20:13:42 2020 +0100
@@ -883,7 +883,7 @@
 </p>
 <a NAME="DebugClientBase.progTerminated" ID="DebugClientBase.progTerminated"></a>
 <h4>DebugClientBase.progTerminated</h4>
-<b>progTerminated</b>(<i>status, message=""</i>)
+<b>progTerminated</b>(<i>status, message="", closeSession=True</i>)
 
 <p>
         Public method to tell the debugger that the program has terminated.
@@ -898,6 +898,10 @@
 <dd>
 status message
 </dd>
+<dt><i>closeSession</i> (bool)</dt>
+<dd>
+flag indicating to close the debugger session
+</dd>
 </dl>
 <a NAME="DebugClientBase.readReady" ID="DebugClientBase.readReady"></a>
 <h4>DebugClientBase.readReady</h4>
--- a/eric6/Documentation/Source/eric6.Preferences.__init__.html	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/Documentation/Source/eric6.Preferences.__init__.html	Sun Dec 20 20:13:42 2020 +0100
@@ -1527,9 +1527,9 @@
 </p>
 <dl>
 
-<dt><i>Qt</i> (int)</dt>
-<dd>
-version to get documentation directory for
+<dt><i>version</i> (int)</dt>
+<dd>
+Qt version to get documentation directory for
 </dd>
 <dt><i>prefClass</i></dt>
 <dd>
--- a/eric6/Preferences/__init__.py	Sun Dec 20 12:35:26 2020 +0100
+++ b/eric6/Preferences/__init__.py	Sun Dec 20 20:13:42 2020 +0100
@@ -2659,7 +2659,7 @@
     """
     Module function to retrieve the Qt5DocDir setting.
     
-    @param Qt version to get documentation directory for
+    @param version Qt version to get documentation directory for
     @type int
     @param prefClass preferences class used as the storage area
     @return the requested Qt5DocDir setting

eric ide

mercurial