No polling of incoming messages. Just wait for a flag. debugger speed

Mon, 18 Jul 2016 22:12:12 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 18 Jul 2016 22:12:12 +0200
branch
debugger speed
changeset 5044
630b9f290a77
parent 5041
f00a4c8bcbbd
child 5045
50862a6a2c63

No polling of incoming messages. Just wait for a flag.

DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugClientBase.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/DebugBase.py	Sun Jul 17 22:40:53 2016 +0200
+++ b/DebugClients/Python/DebugBase.py	Mon Jul 18 22:12:12 2016 +0200
@@ -14,6 +14,8 @@
 import atexit
 import inspect
 import ctypes
+import thread
+import time
 
 from DebugProtocol import ResponseClearWatch, ResponseClearBreak, \
     ResponseLine, ResponseSyntax, ResponseException, CallTrace
@@ -91,6 +93,18 @@
         
         self.__recursionDepth = -1
         self.setRecursionDepth(inspect.currentframe())
+        
+        # background task to periodicaly check for client interactions
+        self.eventPollFlag = False
+        self.timer = thread.start_new_thread(self.__eventPollTimer, ())
+
+    def __eventPollTimer(self):
+        """
+        Private method to set a flag every 0.5 s to check for new messages.
+        """
+        while True:
+            time.sleep(0.5)
+            self.eventPollFlag = True
     
     def getCurrentFrame(self):
         """
@@ -245,7 +259,9 @@
             return  # None
         
         # give the client a chance to push through new break points.
-        self._dbgClient.eventPoll()
+        if self.eventPollFlag:
+            self._dbgClient.eventPoll()
+            self.eventPollFlag = False
         
         if event == 'line':
             if self.stop_here(frame) or self.break_here(frame):
--- a/DebugClients/Python/DebugClientBase.py	Sun Jul 17 22:40:53 2016 +0200
+++ b/DebugClients/Python/DebugClientBase.py	Mon Jul 18 22:12:12 2016 +0200
@@ -13,7 +13,6 @@
 import codeop
 import traceback
 import os
-import time
 import imp
 import re
 import atexit
@@ -1108,15 +1107,6 @@
         if self.pollingDisabled:
             return
         
-        # the choice of a ~0.5 second poll interval is arbitrary.
-        lasteventpolltime = getattr(self, 'lasteventpolltime', time.time())
-        now = time.time()
-        if now - lasteventpolltime < 0.5:
-            self.lasteventpolltime = lasteventpolltime
-            return
-        else:
-            self.lasteventpolltime = now
-
         wrdy = []
         if AsyncPendingWrite(self.writestream):
             wrdy.append(self.writestream)
--- a/DebugClients/Python3/DebugBase.py	Sun Jul 17 22:40:53 2016 +0200
+++ b/DebugClients/Python3/DebugBase.py	Mon Jul 18 22:12:12 2016 +0200
@@ -13,6 +13,8 @@
 import atexit
 import inspect
 import ctypes
+import _thread
+import time
 from inspect import CO_GENERATOR
 
 from DebugProtocol import ResponseClearWatch, ResponseClearBreak, \
@@ -92,6 +94,18 @@
         
         self.__recursionDepth = -1
         self.setRecursionDepth(inspect.currentframe())
+        
+        # background task to periodicaly check for client interactions
+        self.eventPollFlag = False
+        self.timer = _thread.start_new_thread(self.__eventPollTimer, ())
+
+    def __eventPollTimer(self):
+        """
+        Private method to set a flag every 0.5 s to check for new messages.
+        """
+        while True:
+            time.sleep(0.5)
+            self.eventPollFlag = True
     
     def getCurrentFrame(self):
         """
@@ -246,7 +260,9 @@
             return  # None
         
         # give the client a chance to push through new break points.
-        self._dbgClient.eventPoll()
+        if self.eventPollFlag:
+            self._dbgClient.eventPoll()
+            self.eventPollFlag = False
         
         if event == 'line':
             if self.stop_here(frame) or self.break_here(frame):
--- a/DebugClients/Python3/DebugClientBase.py	Sun Jul 17 22:40:53 2016 +0200
+++ b/DebugClients/Python3/DebugClientBase.py	Mon Jul 18 22:12:12 2016 +0200
@@ -13,7 +13,6 @@
 import codeop
 import traceback
 import os
-import time
 import imp
 import re
 import atexit
@@ -1113,15 +1112,6 @@
         if self.pollingDisabled:
             return
         
-        # the choice of a ~0.5 second poll interval is arbitrary.
-        lasteventpolltime = getattr(self, 'lasteventpolltime', time.time())
-        now = time.time()
-        if now - lasteventpolltime < 0.5:
-            self.lasteventpolltime = lasteventpolltime
-            return
-        else:
-            self.lasteventpolltime = now
-
         wrdy = []
         if AsyncPendingWrite(self.writestream):
             wrdy.append(self.writestream)

eric ide

mercurial