Gracefully exit the debugger clients, without loosing last lines.

Sun, 17 Apr 2016 21:26:28 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sun, 17 Apr 2016 21:26:28 +0200
changeset 4943
e093b4e24e97
parent 4942
d6d362104f83
child 4944
d4709f4818bb

Gracefully exit the debugger clients, without loosing last lines.

DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugClientBase.py file | annotate | diff | comparison | revisions
Debugger/DebugServer.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/DebugClientBase.py	Fri Apr 15 19:55:52 2016 +0200
+++ b/DebugClients/Python/DebugClientBase.py	Sun Apr 17 21:26:28 2016 +0200
@@ -584,7 +584,7 @@
                     res = exc.code
                     atexit._run_exitfuncs()
                 self.writestream.flush()
-                self.progTerminated(res, exit=True)
+                self.progTerminated(res)
                 return
 
             if cmd == DebugProtocol.RequestCoverage:
@@ -626,7 +626,7 @@
                 self.cover.stop()
                 self.cover.save()
                 self.writestream.flush()
-                self.progTerminated(res, exit=True)
+                self.progTerminated(res)
                 return
             
             if cmd == DebugProtocol.RequestProfile:
@@ -665,7 +665,7 @@
                     atexit._run_exitfuncs()
                 self.prof.save()
                 self.writestream.flush()
-                self.progTerminated(res, exit=True)
+                self.progTerminated(res)
                 return
 
             if cmd == DebugProtocol.RequestShutdown:
@@ -1047,7 +1047,7 @@
 
     def __interact(self):
         """
-        Private method to Interact with  the debugger.
+        Private method to Interact with the debugger.
         """
         global DebugClientInstance
 
@@ -1071,6 +1071,9 @@
         while self.eventExit is None:
             wrdy = []
 
+            if self.writestream.nWriteErrors > self.writestream.maxtries:
+                break
+            
             if AsyncPendingWrite(self.writestream):
                 wrdy.append(self.writestream)
 
@@ -1304,13 +1307,12 @@
         """
         return self.running
 
-    def progTerminated(self, status, exit=False):
+    def progTerminated(self, status):
         """
         Public method to tell the debugger that the program has terminated.
         
         @param status return status
-        @param exit flag indicating to perform a sys.exit()
-        @type bool
+        @type int
         """
         if status is None:
             status = 0
@@ -1324,9 +1326,6 @@
             self.set_quit()
             self.running = None
             self.write('%s%d\n' % (DebugProtocol.ResponseExit, status))
-            if exit:
-                self.writestream.close(1)
-                sys.exit(status)
         
         # reset coding
         self.__coding = self.defaultCoding
--- a/DebugClients/Python3/DebugClientBase.py	Fri Apr 15 19:55:52 2016 +0200
+++ b/DebugClients/Python3/DebugClientBase.py	Sun Apr 17 21:26:28 2016 +0200
@@ -575,7 +575,7 @@
                         res = exc.code
                         atexit._run_exitfuncs()
                     self.writestream.flush()
-                    self.progTerminated(res, exit=True)
+                    self.progTerminated(res)
                 return
 
             if cmd == DebugProtocol.RequestProfile:
@@ -621,7 +621,7 @@
                         atexit._run_exitfuncs()
                     self.prof.save()
                     self.writestream.flush()
-                    self.progTerminated(res, exit=True)
+                    self.progTerminated(res)
                 return
 
             if cmd == DebugProtocol.RequestCoverage:
@@ -672,7 +672,7 @@
                     self.cover.stop()
                     self.cover.save()
                     self.writestream.flush()
-                    self.progTerminated(res, exit=True)
+                    self.progTerminated(res)
                 return
 
             if cmd == DebugProtocol.RequestShutdown:
@@ -1050,7 +1050,7 @@
 
     def __interact(self):
         """
-        Private method to Interact with  the debugger.
+        Private method to Interact with the debugger.
         """
         global DebugClientInstance
 
@@ -1074,6 +1074,9 @@
         while self.eventExit is None:
             wrdy = []
 
+            if self.writestream.nWriteErrors > self.writestream.maxtries:
+                break
+            
             if AsyncPendingWrite(self.writestream):
                 wrdy.append(self.writestream)
 
@@ -1307,13 +1310,12 @@
         """
         return self.running
 
-    def progTerminated(self, status, exit=False):
+    def progTerminated(self, status):
         """
         Public method to tell the debugger that the program has terminated.
         
         @param status return status
-        @param exit flag indicating to perform a sys.exit()
-        @type bool
+        @type int
         """
         if status is None:
             status = 0
@@ -1327,9 +1329,6 @@
             self.set_quit()
             self.running = None
             self.write('{0}{1:d}\n'.format(DebugProtocol.ResponseExit, status))
-            if exit:
-                self.writestream.close(True)
-                sys.exit(status)
         
         # reset coding
         self.__coding = self.defaultCoding
--- a/Debugger/DebugServer.py	Fri Apr 15 19:55:52 2016 +0200
+++ b/Debugger/DebugServer.py	Sun Apr 17 21:26:28 2016 +0200
@@ -1339,7 +1339,8 @@
         if self.passive:
             self.__passiveShutDown()
         self.clientExit.emit(int(status))
-        if Preferences.getDebugger("AutomaticReset"):
+        if Preferences.getDebugger("AutomaticReset") or (self.running and
+                                                         not self.debugging):
             self.startClient(False)
         if self.passive:
             self.__createDebuggerInterface("None")

eric ide

mercurial