Selaa lähdekoodia

*** empty log message ***

Joe Shochet 24 vuotta sitten
vanhempi
sitoutus
3103d5d4e7
1 muutettua tiedostoa jossa 39 lisäystä ja 0 poistoa
  1. 39 0
      direct/src/task/Task.py

+ 39 - 0
direct/src/task/Task.py

@@ -12,6 +12,43 @@ exit = -1
 done = 0
 cont = 1
 
+def print_exc_plus():
+    """
+    Print the usual traceback information, followed by a listing of all the
+    local variables in each frame.
+    """
+    import sys
+    import traceback
+
+    tb = sys.exc_info()[2]
+    while 1:
+        if not tb.tb_next:
+            break
+        tb = tb.tb_next
+    stack = []
+    f = tb.tb_frame
+    while f:
+        stack.append(f)
+        f = f.f_back
+    stack.reverse()
+    traceback.print_exc()
+    print "Locals by frame, innermost last"
+    for frame in stack:
+        print
+        print "Frame %s in %s at line %s" % (frame.f_code.co_name,
+                                             frame.f_code.co_filename,
+                                             frame.f_lineno)
+        for key, value in frame.f_locals.items():
+            print "\t%20s = " % key,
+            #We have to be careful not to cause a new error in our error
+            #printer! Calling str() on an unknown object could cause an
+            #error we don't want.
+            try:                   
+                print value
+            except:
+                print "<ERROR WHILE PRINTING VALUE>"
+
+
 # Store the global clock
 globalClock = ClockObject.getGlobalClock()
 
@@ -460,6 +497,8 @@ class TaskManager:
                 except KeyboardInterrupt:
                     self.stop()
                 except:
+                    # self.stop()
+                    # print_exc_plus()
                     raise
 
     def stop(self):