Question about the 'code' module
Fernando Perez
fperez.net at gmail.com
Thu Dec 29 18:25:38 EST 2005
Thomas Heller wrote:
> I'm using the code module to implement an interactive interpreter
> console in a GUI application, the interpreter running in a separate
> thread. To provide clean shutdown of the application, I have to make
> sure that objects used in the interpreter thread are deleted when the
> thread ends.
>
> I delete the sys.last_type, sys.last_value, and sys.last_traceback
> attributes which are set when an exception occured in the interpreter
> thread (*). To clean up the '_' symbol that the interpreter maintains,
> I have found no other solution than to execute 'console.runsource("0")'
> at the end of the thread. Where is this symbol stored? How can I delete
> it without the .runsource() call?
Wild guess: try defining your own sys.displayhook to manage output. This may be
done there, though I'm not really sure. Otherwise, it's done by the
interpreter internally when exec is called on a code object compiled in
'single' mode.
Cheers,
f
More information about the Python-list
mailing list