annotate MoinMoin/util/thread_monitor.py @ 2595:5e7b45489430

moved python2.3/2.4 compatibility code to MoinMoin.support.python_compatibility (thanks to Heinrich Wendel)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 03 Aug 2007 13:30:42 +0200
parents 01f05e74aa9c
children 500f68d3e2fd
rev   line source
712
6ff5221f7e18 Made thread_monitor 8bit clean and added epydoc formatting.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 674
diff changeset
1 # -*- coding: ascii -*-
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
2 """
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
3 Thread monitor - Check the state of all threads.
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
5 Just call activate_hook() as early as possible in program execution.
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
6 Then you can trigger the output of tracebacks of all threads
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
7 by calling trigger_dump().
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
8
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
9 Usage of Python 2.5 is recommended because it allows for a much safer
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
10 and faster frame extraction.
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
11
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
12 @copyright: 2006 Alexander Schremmer <alex AT alexanderweb DOT de>
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1870
diff changeset
13 @license: GNU GPL Version 2
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
14 """
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
15
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
16
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
17 __all__ = "activate_hook trigger_dump dump_regularly".split()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
18
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
19
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
20 import sys
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
21 import threading
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
22 import traceback
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
23 from time import sleep
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
24 from StringIO import StringIO
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
25
2595
5e7b45489430 moved python2.3/2.4 compatibility code to MoinMoin.support.python_compatibility (thanks to Heinrich Wendel)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
26 from MoinMoin.support.python_compatibility import set
5e7b45489430 moved python2.3/2.4 compatibility code to MoinMoin.support.python_compatibility (thanks to Heinrich Wendel)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
27
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
28
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
29 class AbstractMonitor(object):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
30 def activate_hook(self):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
31 """ Activates the thread monitor hook. Note that this might interfere
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
32 with any kind of profiler and some debugging extensions. """
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
33 raise NotImplementedError
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 835
diff changeset
34
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
35 def trigger_dump(self, dumpfile=None):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
36 """ Triggers the dump of the tracebacks of all threads.
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
37 If dumpfile is specified, it is used as the output file. """
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
38 raise NotImplementedError
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
39
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
40 def hook_enabled(self):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
41 """ Returns true if the thread_monitor hook is enabled. """
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
42 raise NotImplementedError
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
43
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
44 class LegacyMonitor(AbstractMonitor):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
45 # global state
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
46 dumping = False
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
47 dump_file = None
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
48 dumped = set()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
49 to_dump = set()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
50 hook_enabled = False
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
51
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
52 def dump(cls, label):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
53 df = cls.dump_file or sys.stderr
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
54 s = StringIO()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
55 print >>s, "\nDumping thread %s:" % (label, )
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
56 try:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
57 raise ZeroDivisionError
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
58 except ZeroDivisionError:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
59 f = sys.exc_info()[2].tb_frame.f_back.f_back
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
60 traceback.print_list(traceback.extract_stack(f, None), s)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
61 df.write(s.getvalue())
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
62 dump = classmethod(dump)
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
63
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
64 def dump_hook(cls, a, b, c): # arguments are ignored
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
65 if cls.dumping and sys.exc_info()[0] is None:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
66 thread = threading.currentThread()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
67 if thread in cls.to_dump:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
68 cls.dump(repr(thread))
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
69 cls.to_dump.discard(thread)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
70 cls.dumped.add(thread)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
71 if not cls.to_dump:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
72 cls.dumping = False
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
73 dump_hook = classmethod(dump_hook)
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 835
diff changeset
74
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
75 def trigger_dump(cls, dumpfile=None):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
76 cls.to_dump = set(threading.enumerate())
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
77 if dumpfile is not None:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
78 cls.dump_file = dumpfile
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
79 cls.dumping = True
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
80 trigger_dump = classmethod(trigger_dump)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
81
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
82 def activate_hook(cls):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
83 sys.setprofile(cls.dump_hook)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
84 threading.setprofile(cls.dump_hook)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
85 cls.hook_enabled = True
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
86 activate_hook = classmethod(activate_hook)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
87
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
88 def hook_enabled(cls):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
89 return cls.hook_enabled
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
90 hook_enabled = classmethod(hook_enabled)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
91
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
92
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
93 class DirectMonitor(AbstractMonitor):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
94 def __init__(self):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
95 self.enabled = False
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
96 assert hasattr(sys, "_current_frames")
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
97
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
98 def activate_hook(self):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
99 self.enabled = True
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
100
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
101 def trigger_dump(self, dumpfile=None):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
102 if not self.enabled:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
103 return
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
104 dumpfile = dumpfile or sys.stderr
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
105 cur_frames = sys._current_frames()
1870
9406e02388cf reduce usage of .keys()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1528
diff changeset
106 for i in cur_frames:
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
107 s = StringIO()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
108 print >>s, "\nDumping thread (id %s):" % (i, )
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
109 traceback.print_stack(cur_frames[i], file=s)
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
110 dumpfile.write(s.getvalue())
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
111
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
112 def hook_enabled(self):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
113 return self.enabled
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
114
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
115
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
116 def dump_regularly(seconds):
712
6ff5221f7e18 Made thread_monitor 8bit clean and added epydoc formatting.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 674
diff changeset
117 """ Dumps the tracebacks every 'seconds' seconds. """
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
118 activate_hook()
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
119
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
120 def background_dumper(seconds):
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
121 while 1:
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
122 sleep(seconds)
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
123 trigger_dump()
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 835
diff changeset
124
674
b4a6bad53f91 Added thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents:
diff changeset
125 threading.Thread(target=background_dumper, args=(seconds, )).start()
835
d4dd4fca1477 moved action/tm to action/thread_monitor, minor cleanup, added CHANGES entry about thread_monitor action
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 712
diff changeset
126
1528
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
127
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
128 # Python 2.5 provides an optimised version
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
129 if hasattr(sys, "_current_frames"):
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
130 mon = DirectMonitor()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
131 else:
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
132 mon = LegacyMonitor()
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
133
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
134 activate_hook = mon.activate_hook
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
135 trigger_dump = mon.trigger_dump
ec52fba7f971 Added support for Python 2.5 in the thread monitor.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1004
diff changeset
136 hook_enabled = mon.hook_enabled