Added some inspirations received from Tobias. multi_processing

Wed, 29 Jan 2020 19:38:13 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 29 Jan 2020 19:38:13 +0100
branch
multi_processing
changeset 7376
21df384d6150
parent 7375
af2500ced7e0
child 7377
cc920e534ac0

Added some inspirations received from Tobias.

eric6/DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
eric6/DebugClients/Python/ThreadExtension.py file | annotate | diff | comparison | revisions
eric6/Debugger/DebugViewer.py file | annotate | diff | comparison | revisions
eric6/Debugger/DebuggerInterfacePython.py file | annotate | diff | comparison | revisions
--- a/eric6/DebugClients/Python/DebugBase.py	Wed Jan 29 18:47:35 2020 +0100
+++ b/eric6/DebugClients/Python/DebugBase.py	Wed Jan 29 19:38:13 2020 +0100
@@ -89,6 +89,7 @@
         self.skipFrames = 0
         
         self.isBroken = False
+        self.isException = False
         self.cFrame = None
         
         # current frame we are at
@@ -881,6 +882,7 @@
             self.stop_everywhere = False
         
         self.isBroken = True
+        self.isException = True
         
         stack = []
         if exctb:
@@ -904,6 +906,7 @@
         self.skipFrames = 0
         
         self.isBroken = False
+        self.isException = False
         stop_everywhere = self.stop_everywhere
         self.stop_everywhere = False
         self.eventPollFlag = False
@@ -925,7 +928,7 @@
             else:
                 return exctype
         else:
-            return str(exctype).replace("<class '", "").replace("'>", "")
+            return exctype.__name__
     
     def __extract_stack(self, exctb):
         """
--- a/eric6/DebugClients/Python/DebugClientBase.py	Wed Jan 29 18:47:35 2020 +0100
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Wed Jan 29 19:38:13 2020 +0100
@@ -79,25 +79,36 @@
         DebugClientOrigRawInput = __builtins__.__dict__['raw_input']
         __builtins__.__dict__['raw_input'] = DebugClientRawInput
     except (AttributeError, KeyError):
-        import __main__
-        DebugClientOrigRawInput = __main__.__builtins__.__dict__['raw_input']
-        __main__.__builtins__.__dict__['raw_input'] = DebugClientRawInput
+        try:
+            import __main__
+            DebugClientOrigRawInput = __main__.__builtins__.__dict__[
+                'raw_input'
+            ]
+            __main__.__builtins__.__dict__['raw_input'] = DebugClientRawInput
+        except (AttributeError, KeyError):
+            DebugClientOrigRawInput = lambda x: ''  # __IGNORE_WARNING__
 
     try:
         DebugClientOrigInput = __builtins__.__dict__['input']
         __builtins__.__dict__['input'] = DebugClientInput
     except (AttributeError, KeyError):
-        import __main__
-        DebugClientOrigInput = __main__.__builtins__.__dict__['input']
-        __main__.__builtins__.__dict__['input'] = DebugClientInput
+        try:
+            import __main__
+            DebugClientOrigInput = __main__.__builtins__.__dict__['input']
+            __main__.__builtins__.__dict__['input'] = DebugClientInput
+        except (AttributeError, KeyError):
+            DebugClientOrigInput = lambda x: ''  # __IGNORE_WARNING__
 else:
     try:
         DebugClientOrigInput = __builtins__.__dict__['input']
         __builtins__.__dict__['input'] = DebugClientRawInput
     except (AttributeError, KeyError):
-        import __main__
-        DebugClientOrigInput = __main__.__builtins__.__dict__['input']
-        __main__.__builtins__.__dict__['input'] = DebugClientRawInput
+        try:
+            import __main__
+            DebugClientOrigInput = __main__.__builtins__.__dict__['input']
+            __main__.__builtins__.__dict__['input'] = DebugClientRawInput
+        except (AttributeError, KeyError):
+            DebugClientOrigInput = lambda x: ''  # __IGNORE_WARNING__
 
 ###############################################################################
 
@@ -235,6 +246,8 @@
         self.defaultCoding = 'utf-8'
         self.__coding = self.defaultCoding
         self.noencoding = False
+        
+        self.startOptions = None
     
     def getCoding(self):
         """
@@ -2192,6 +2205,13 @@
                 print("No program given. Aborting!")
                 # __IGNORE_WARNING_M801__
             else:
+                # Store options if a process is spawn
+                # TODO: check which ones are really needed
+                self.startOptions = (
+                    wd, host, port, exceptions, tracePython, redirect,
+                    self.noencoding, self.fork_auto, self.fork_child,
+                    self.pids
+                )
                 if not self.noencoding:
                     self.__coding = self.defaultCoding
                 self.startProgInDebugger(args, wd, host, port,
@@ -2236,6 +2256,13 @@
                 sys.path.insert(0, '')
             
             if port >= 0:
+                # Store options if a process is spawn
+                # TODO: check which ones are really needed
+                self.startOptions = (
+                    '', remoteAddress, port, True, False, redirect,
+                    self.noencoding, self.fork_auto, self.fork_child,
+                    self.pids
+                )
                 if not self.noencoding:
                     self.__coding = self.defaultCoding
                 self.connectDebugger(port, remoteAddress, redirect)
--- a/eric6/DebugClients/Python/ThreadExtension.py	Wed Jan 29 18:47:35 2020 +0100
+++ b/eric6/DebugClients/Python/ThreadExtension.py	Wed Jan 29 19:38:13 2020 +0100
@@ -7,7 +7,7 @@
 Module implementing an import hook patching thread modules to get debugged too.
 """
 
-import os.path
+import os
 import sys
 import importlib
 
@@ -176,9 +176,11 @@
                 try:
                     d["name"] = threadNames.get(threadId, thd.name)
                     d["broken"] = thd.isBroken
+                    d["except"] = thd.isException
                 except Exception:
                     d["name"] = 'UnknownThread'
                     d["broken"] = False
+                    d["except"] = False
                 
                 threadList.append(d)
         else:
@@ -186,6 +188,7 @@
             d = {"id": -1}
             d["name"] = "MainThread"
             d["broken"] = self.isBroken
+            d["except"] = self.isException
             threadList.append(d)
         
         self.sendJsonCommand("ResponseThreadList", {
--- a/eric6/Debugger/DebugViewer.py	Wed Jan 29 18:47:35 2020 +0100
+++ b/eric6/Debugger/DebugViewer.py	Wed Jan 29 19:38:13 2020 +0100
@@ -482,13 +482,19 @@
         
         self.__threadList.clear()
         for thread in threadList:
-            if thread['broken']:
+            if thread.get('except', False):
+                state = self.tr("waiting at exception")
+                icon = "exceptions.png"
+            elif thread['broken']:
                 state = self.tr("waiting at breakpoint")
+                icon = "mediaPlaybackPause.png"
             else:
                 state = self.tr("running")
+                icon = "mediaPlaybackStart.png"
             itm = QTreeWidgetItem(self.__threadList,
                                   ["{0:d}".format(thread['id']),
                                    thread['name'], state])
+            itm.setIcon(0, UI.PixmapCache.getIcon(icon))
             if thread['id'] == currentID:
                 citm = itm
         
--- a/eric6/Debugger/DebuggerInterfacePython.py	Wed Jan 29 18:47:35 2020 +0100
+++ b/eric6/Debugger/DebuggerInterfacePython.py	Wed Jan 29 19:38:13 2020 +0100
@@ -1114,7 +1114,6 @@
 ##            print("Server: ", line)          ##debug
             
             self.__handleJsonCommand(line, sock)
-            continue
     
     def __handleJsonCommand(self, jsonStr, sock):
         """

eric ide

mercurial