Commit | Line | Data |
---|---|---|
342c8c21 FT |
1 | """Python Daemon Management -- Miscellaneous utilities |
2 | ||
3 | This module contains various functions that may be useful to call from | |
4 | the PDM REPL. | |
5 | """ | |
6 | ||
7 | import sys, traceback, threading | |
8 | ||
9 | def threads(): | |
10 | "Returns a dict of currently known threads, mapped to their respective frames." | |
11 | tt = dict((th.ident, th) for th in threading.enumerate()) | |
12 | return dict((tt.get(key, key), val) for key, val in sys._current_frames().iteritems()) | |
13 | ||
14 | def traces(): | |
15 | "Returns the value of threads() with each frame expanded to a backtrace." | |
16 | return dict((th, traceback.extract_stack(frame)) for th, frame in threads().iteritems()) |