Unload extension modules when python22.dll unloads... [using C extension interpreter]

Tim Daneliuk tundra at tundraware.com
Thu Nov 6 19:13:52 CET 2003

Anand wrote:

> I have a unexpected issue with python modules (well i kind of know
> why, but i am trying to find if there is a way around)
> Intro:
> I am allowing an external application to actually run python scripts.
> The external application i am taking about is a test sequencer with a
> lots of functionality. So the external application has a lot of gui
> and all the testing logic is done in python. Things work fine when i
> run regular code and i have been running python code successfully
> (several thousand lines of code) for over eight months.
> Issue:
>       Well, now there is an requirement to throw a dialog box from
> python. I built a wxpython code and was able to successfully show the
> dialog box from python. But when i run the code for the second time,
> it wouldnt work..
> the wxpython's dll probably does some initialization during
> dll_process_attach... but i never see the pyd get unloaded ( i
> actually unload python22.dll after each run). this is a big problem
> now. i did not really consider about this earlier. so i cannot
> actually Guarantee proper fuctioning of the python code...
> is there a way for me to *unload dynamically loaded extension module*
> each time and then reload it each time when the code is called...
> thanks a lot in advance.

Another thought: If you are running on Win32, (iirc) there is a way to
present a dialog box directly from a python script using win32all. This
method, while not portable, has the advantage of not having to go
through all the usual GUI gobbledy-gook to set up and process the dialog

import win32gui

retval = win32gui.DialogBox(....)

Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/

More information about the Python-list mailing list