summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2003-06-29 16:58:41 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2003-06-29 16:58:41 (GMT)
commitbfccb35b58c84ec186bb1e38d028754796b1fbcf (patch)
tree0dab0787577eee7074ce626ffe26801ad1fbb357 /Lib
parentc98ccfd29f404ccef7c3fd7a7c1cbbb8d024dce7 (diff)
downloadcpython-bfccb35b58c84ec186bb1e38d028754796b1fbcf.zip
cpython-bfccb35b58c84ec186bb1e38d028754796b1fbcf.tar.gz
cpython-bfccb35b58c84ec186bb1e38d028754796b1fbcf.tar.bz2
Add settrace() and setprofile() functions to the threading library.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/threading.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 7ec8eff..f48fb6e 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -52,6 +52,18 @@ else:
def _note(self, *args):
pass
+# Support for profile and trace hooks
+
+_profile_hook = None
+_trace_hook = None
+
+def setprofile(func):
+ global _profile_hook
+ _profile_hook = func
+
+def settrace(func):
+ global _trace_hook
+ _trace_hook = func
# Synchronization classes
@@ -408,6 +420,14 @@ class Thread(_Verbose):
_active_limbo_lock.release()
if __debug__:
self._note("%s.__bootstrap(): thread started", self)
+
+ if _trace_hook:
+ self._note("%s.__bootstrap(): registering trace hook", self)
+ _sys.settrace(_trace_hook)
+ if _profile_hook:
+ self._note("%s.__bootstrap(): registering profile hook", self)
+ _sys.setprofile(_profile_hook)
+
try:
self.run()
except SystemExit: