Merge branch 'master' of ansgar.seatribe.se:/usr/local/src/pdm
[pdm.git] / pdm / util.py
CommitLineData
342c8c21
FT
1"""Python Daemon Management -- Miscellaneous utilities
2
3This module contains various functions that may be useful to call from
4the PDM REPL.
5"""
6
7import sys, traceback, threading
8
9def threads():
10 "Returns a dict of currently known threads, mapped to their respective frames."
fbaf5844
FT
11 tt = {th.ident: th for th in threading.enumerate()}
12 return {tt.get(key, key): val for key, val in sys._current_frames().items()}
342c8c21
FT
13
14def traces():
15 "Returns the value of threads() with each frame expanded to a backtrace."
fbaf5844 16 return {th: traceback.extract_stack(frame) for th, frame in threads().items()}