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

A

Anand

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.
 
T

Tim Daneliuk

Anand said:
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(....)

HTH,
 
A

Anand

Tim,
thanks a lot for your suggestions. this is lot simpler than my
wxpython approach.

Thanks,
Anand.
 
T

Tim Daneliuk

Anand said:
Tim,
thanks a lot for your suggestions. this is lot simpler than my
wxpython approach.

Thanks,
Anand.


There is, of course, still _some_ fiddling around you have to do to setup
the Box for native Win32 API calls ... I'd be interested in seeing a
sample of the code when you get it working...

The one downside of doing things this way (beyond the lack of portability)
is that you do have to know the win32 apis well, which I do not. But it
does seem to be a more quick-n-dirty approach than having to go through
all the overhead of wxWin or Tkinter setup ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,133
Latest member
MDACVReview
Top