Interpreter hook during evaluation

Diez B. Roggisch deets at nospam.web.de
Fri Oct 26 13:23:01 EDT 2007


WilliamKF at gmail.com schrieb:
> Hello,
> 
> I would like access to a hook inside Python that would allow me to
> register a C++ function to be called periodically during the
> evaluation of a Python script.
> 
> Does any such thing exist today in Python? I poked around but didn't
> find anything.
> 
> I want to do this for interrupt handling. I'd like to be able to
> interrupt long running Python commands. I have a hook which would
> throw a C++ exception if an interrupt is detected. I would then catch
> this at the place where my application which embeds Python invokes a
> Python command. My hook is written to be very fast, so calling it
> every Python instruction would not be that bad in terms of
> performance.
> 
> I'd like to avoid changing the existing Python implementation, which
> is why I'm looking for a hook. Otherwise, a user would not be able to
> substitute in their own Python implementation if they so desire
> instead of taking the default on our app uses.

trace.

http://www.dalkescientific.com/writings/diary/archive/2005/04/20/tracing_python_code.html


Diez



More information about the Python-list mailing list