Python.DebugClientBase: : changed the run logic to (hopefully) cope with a situation causing 100% CPU load when the IDE is not shut down cleanly.

Mon, 12 Nov 2018 19:48:08 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Nov 2018 19:48:08 +0100
changeset 6588
a77723d4060f
parent 6587
a04952159050
child 6589
613426e62983

Python.DebugClientBase: : changed the run logic to (hopefully) cope with a situation causing 100% CPU load when the IDE is not shut down cleanly.

DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
diff -r a04952159050 -r a77723d4060f DebugClients/Python/DebugClientBase.py
--- a/DebugClients/Python/DebugClientBase.py	Sat Nov 10 11:06:56 2018 +0100
+++ b/DebugClients/Python/DebugClientBase.py	Mon Nov 12 19:48:08 2018 +0100
@@ -1063,10 +1063,11 @@
         @param disablePolling flag indicating to enter an event loop with
             polling disabled (boolean)
         """
-        self.eventExit = None
+        self.eventExit = False
         self.pollingDisabled = disablePolling
+        selectErrors = 0
 
-        while self.eventExit is None:
+        while not self.eventExit:
             wrdy = []
 
             if self.writestream.nWriteErrors > self.writestream.maxtries:
@@ -1081,9 +1082,17 @@
             try:
                 rrdy, wrdy, xrdy = select.select([self.readstream], wrdy, [])
             except (select.error, KeyboardInterrupt, socket.error):
-                # just carry on
-                continue
-
+                selectErrors += 1
+                if selectErrors <= 10:      # arbitrarily selected
+                    # just carry on
+                    continue
+                else:
+                    # give up for too many errors
+                    break
+            
+            # reset the select error counter
+            selectErrors = 0
+            
             if self.readstream in rrdy:
                 error = self.readReady(self.readstream)
                 if error:
@@ -1095,7 +1104,7 @@
             if self.errorstream in wrdy:
                 self.writeReady(self.errorstream)
 
-        self.eventExit = None
+        self.eventExit = False
         self.pollingDisabled = False
 
     def eventPoll(self):

eric ide

mercurial