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 c
You can try to peek into your stacktrace.
https://docs.python.org/library/inspect.html#the-interpreter-stack
when you try this in a debugger session:
import inspect
inspect.getouterframes(inspect.currentframe()
you will get a list of framerecords and can peek for any frames that refer to the pdb file.
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.