[Pythonmac-SIG] Embedding in code resource
Jason Harper
JasonRandHarper@compuserve.com
Wed, 21 Nov 2001 14:43:14 -0500
Jack Jansen wrote:
> what you want to do is probably
> PyMac_Initialize();
> PyRun_AnyFile(stdin_for_python, "<stdin>");
> I think this should never call exit(), but always return.
> =
> Depending on how your code resource is linked against PythonCore you ma=
y
be =
> able to do simply "stdin" for stdin_for_python, but it could also be mo=
re
work =
> to get at that.
Running an interactive loop isn't the problem, it's what happens
afterwards... When my plug-in is deselected by the user, I need to clean=
ly
finalize the interpreter (free at least most of its memory, close the SIO=
UX
console if it was opened, etc.), and let the parent application continue
running. Py_Exit() and PyMac_Exit() eventually call exit(), and I'm not
sure that can be avoided anyway - it appears that SIOUX's cleanup is done=
by an atexit() handler. I guess what I really need is a way to intercept=
the exit() in PythonCore before it can exit the parent application.
Jason Harper