Browse Source

fixed mismatched-spike-task bug

Darren Ranalli 17 years ago
parent
commit
9b36b7b487
1 changed files with 21 additions and 14 deletions
  1. 21 14
      direct/src/task/Task.py

+ 21 - 14
direct/src/task/Task.py

@@ -388,9 +388,11 @@ class TaskManager:
         # this will be set when it's safe to import StateVar
         # this will be set when it's safe to import StateVar
         self._profileTasks = None
         self._profileTasks = None
         self._taskProfiler = None
         self._taskProfiler = None
-        self._profileTaskId = None
-        self._profileDt = None
-        self._lastProfileResultString = None
+        self._profileInfo = ScratchPad(
+            taskId = None,
+            dt = None,
+            lastProfileResultString = None,
+            )
 
 
         # We copy this value in from __builtins__ when it gets set.
         # We copy this value in from __builtins__ when it gets set.
         # But since the TaskManager might have to run before it gets
         # But since the TaskManager might have to run before it gets
@@ -760,9 +762,12 @@ class TaskManager:
 
 
     def __executeTask(self, task):
     def __executeTask(self, task):
         task.setCurrentTimeFrame(self.currentTime, self.currentFrame)
         task.setCurrentTimeFrame(self.currentTime, self.currentFrame)
-
-        doProfile = (task.id == self._profileTaskId)
-            
+        
+        # cache reference to profile info here, self._profileInfo might get swapped out
+        # by the task when it runs
+        profileInfo = self._profileInfo
+        doProfile = (task.id == profileInfo.taskId)
+        
         if not self.taskTimerVerbose:
         if not self.taskTimerVerbose:
             startTime = self.trueClock.getShortTime()
             startTime = self.trueClock.getShortTime()
             
             
@@ -779,7 +784,7 @@ class TaskManager:
             if doProfile:
             if doProfile:
                 # if we profiled, record the measured duration but don't pollute the task's
                 # if we profiled, record the measured duration but don't pollute the task's
                 # normal duration
                 # normal duration
-                self._profileDt = dt
+                profileInfo.dt = dt
                 dt = task.avgDt
                 dt = task.avgDt
             task.dt = dt
             task.dt = dt
 
 
@@ -802,7 +807,7 @@ class TaskManager:
             if doProfile:
             if doProfile:
                 # if we profiled, record the measured duration but don't pollute the task's
                 # if we profiled, record the measured duration but don't pollute the task's
                 # normal duration
                 # normal duration
-                self._profileDt = dt
+                profileInfo.dt = dt
                 dt = task.avgDt
                 dt = task.avgDt
             task.dt = dt
             task.dt = dt
 
 
@@ -818,7 +823,7 @@ class TaskManager:
                 task.avgDt = 0
                 task.avgDt = 0
 
 
         if doProfile:
         if doProfile:
-            self._lastProfileResultString = self._getProfileResultString()
+            profileInfo.lastProfileResultString = self._getProfileResultString()
 
 
         # warn if the task took too long
         # warn if the task took too long
         if self.warnTaskDuration and self.globalClock:
         if self.warnTaskDuration and self.globalClock:
@@ -965,15 +970,17 @@ class TaskManager:
             self._taskProfiler = TaskProfiler()
             self._taskProfiler = TaskProfiler()
 
 
     def _setProfileTask(self, task):
     def _setProfileTask(self, task):
-        self._profileTaskId = task.id
-        self._profileDt = None
-        self._lastProfileResultString = None
+        self._profileInfo = ScratchPad(
+            taskId = task.id,
+            dt = None,
+            lastProfileResultString = None,
+            )
 
 
     def _getTaskProfileDt(self):
     def _getTaskProfileDt(self):
-        return self._profileDt
+        return self._profileInfo.dt
 
 
     def _getLastProfileResultString(self):
     def _getLastProfileResultString(self):
-        return self._lastProfileResultString
+        return self._profileInfo.lastProfileResultString
 
 
     def _getRandomTask(self):
     def _getRandomTask(self):
         numTasks = 0
         numTasks = 0