> Everything works fine for the first time (python initialize/shell start/
shell 
> terminate/ python finalize) But after a while I realized that I need to 
> reinitialize python and start all over again. 

> The problem is that I have no control over loading and unloading my dll 
> Which means that the dll stays attached to the application process after 
> detaching from a chart and somehow it becomes the source of evil the 
> second time I try to attach it to a chart and I get this traceback[1] in 
> the pystartshell function when I try to create the wx app. 

Sadly, Python dies in a number of creative ways with multiple init/finalize
cycles.  I'd suggest simply not even trying to unload Python - just keep a
flag for yourself.  This means it might be almost impossible to ever call
Py_Finalize (calling from your DllMain as you are unloaded is unlikely to be
reliable either) - Windows will cope - but exit hooks and finalizers for
objects which are still alive will not run.  If it is any consolation,
Python is also never finalized when a win32com object causes Python to be
loaded into a process either...

Cheers,

Mark

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to