Is there a simple way to detect, within Python code, that this code is being executed through the Python debugger?
I have a small Python application that uses Java code (thanks to JPype). When I'm debugging the Python part, I'd like the embedded JVM to be passed debug options too.
Python debuggers (as well as profilers and coverage tools) use the sys.settrace
function (in the sys
module) to register a callback that gets called when interesting events happen.
If you're using Python 2.6, you can call sys.gettrace()
to get the current trace callback function. If it's not None
then you can assume you should be passing debug parameters to the JVM.
It's not clear how you could do this pre 2.6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With