https://github.com/wagoodman/pydebugshell
A python module which can be used to interrupt a script and inspect running objects or self destruct a run-away script
https://github.com/wagoodman/pydebugshell
debugger python
Last synced: 7 months ago
JSON representation
A python module which can be used to interrupt a script and inspect running objects or self destruct a run-away script
- Host: GitHub
- URL: https://github.com/wagoodman/pydebugshell
- Owner: wagoodman
- Created: 2014-08-28T20:04:39.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-08-28T20:22:19.000Z (about 11 years ago)
- Last Synced: 2025-01-23T16:23:17.026Z (9 months ago)
- Topics: debugger, python
- Language: Python
- Size: 133 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PyDebugShell
============A python module which can be used to interrupt a script and inspect running objects or self destruct a run-away script
Strike Ctrl+\ during execution of any python script which utilizes this module to get to an interactive pythgon shell and inspect local/global objects:
```
===[ COMMANDS ]===List Objects:
report
report more
dir()
locals()
globals()
Inspect a specific object:
debug.ObjSize.getSize( obj )
debug.showObj( obj )
Process Information:
proc
Test the self destruct:
stress test-----------------------------------------------------------------
Debug Shell.
>>>```
Import the debug module and add a specific try/except anywhere in your code:
```python
import debug
import timedef main():
try:
while True:
...
...except debug.DebugException:
exec debug.normalHandler
except debug.SelfDestructException, message:
print message
finally:
debug.selfDestructThread.stop()
debug.selfDestructThread.join()
```Or use the given decorator on a long running method:
```python
@debug.DebugSession(globals())
def main():
...
...main()
```If the CPU utilization goes beyond 10% for a long enough duration, or memory utilization spikes above 1024MB then
the process will automatically killed and show this message:```
Proc 19008 killed because it took up too many resources!
CPU Percent [Cur/Avg/Threshold]: 17.7 / 4.25 / 10.0
Mem KBytes [Cur/Avg/Threshold]: 180612.0 / 102968.8 / 102400.0
```This is not production worthy! Please only use this while developing.