3 ms·
Nice article. In particular the -i flag seems really useful. I'd like to add two packages I learned about recently that I like A LOT: pyrasite and PySnooper.
by ivan_ah 6y ago
Nice article. In particular the -i flag seems really useful.
I'd like to add two packages I learned about recently that I like A LOT: pyrasite and PySnooper.
Use pyrasite to "attach" to an existing running Python process (i.e. you forgot to instrument the app, but it has a bug in it, how can you debug?)
(1) Install pyrasite
(2) Get the PID of the running process
(3) Run `pyrasite <pid> dumpstackz0.py` where dumpstackz0.pycontains `import traceback; traceback.print_stack()`
(4) The stacktrace will be printed in the stdout/stderr of the running application
Use PySnooper instead of print-debugging—just add a decorator to any python function to get detailed debug info like you normally would get from a full debugger:
(A) code: https://github.com/cool-RR/PySnooper https://github.com/cool-RR/PySnooper
(B) pypi: https://pypi.org/project/PySnooper/ https://pypi.org/project/PySnooper/
(C) talk: https://www.youtube.com/watch?v=XP5imOJc_TE https://www.youtube.com/watch?v=XP5imOJc_TE
(D) podcast: https://www.youtube.com/watch?v=VUZvgJJKor0 https://www.youtube.com/watch?v=VUZvgJJKor0
- macintux 6y agoThat -i flag trick would have saved me a lot of grief over the last year or so. Better late than never.