Commits

jayven committed 88fd7a1

Rename some args

Comments (0)

Files changed (1)

 import sys, threading
 
 
-# thread-local storage for hotdebug
-_hotdebug_tls = threading.local()
+__all__ = ['register_exception_callback', 'unregister_exception_callback']
+
+
+# thread-local storage for exception callback
+_exception_callback_tls = threading.local()
 
 
 def register_exception_callback(cb):
-    _hotdebug_tls.exception_callback = cb
+    '''
+    Register a thread-local callback that will be called when THIS thread
+    has uncaught exception
+    '''
+    _exception_callback_tls.cb = cb
 
 
 def unregister_exception_callback():
-    if getattr(_hotdebug_tls, 'exception_callback', None):
-        del _hotdebug_tls.exception_callback
+    '''
+    Reverse op of register_exception_callback
+    '''
+    if getattr(_exception_callback_tls, 'cb', None):
+        del _exception_callback_tls.cb
 
 
 def _hook_excpetion():
             try:
                 return old(self, method, auth, params)
             except:
-                cb = getattr(_hotdebug_tls, 'exception_callback', None)
+                cb = getattr(_exception_callback_tls, 'cb', None)
                 # only process the same thread's exception
                 if cb is not None:
                     cb(*sys.exc_info())