Module initialization problem when using COM

Robin Boerdijk robin.boerdijk at nl.origin-it.com
Wed May 26 14:06:53 EDT 1999


I tried Marks suggestion and it behaves as expected: the initialization
function is called multiple times within the same DLL instance. Apperently,
Robin was right all along. Sorry it took so long for me to catch up, I had
to climb the DLL learning curve first.

My conclusion is that we need to do the following:

1. Record somewhere that module initialization functions should be
re-executable. Currently, the Python documentation only states: "When the
Python program imports module spam for the first time, initspam() is
called." This is what made me believe that an initialization function could
never be called more than once. I don't know what the correct place for this
is, the FAQ or the Python documentation itself.

2. I'll ask the ILU guys to make their initialization function re-executable
(as suggested by Robin in the first place).

Thanks for your help everyone,

Robin Boerdijk

Robin Becker <robin at jessikat.demon.co.uk> wrote in message
news:hR9ZnGAiR8S3EwQ0 at jessikat.demon.co.uk...
> In article <7ifioj$rhi$1 at m2.c2.telstra-mm.net.au>, Mark Hammond
> <MHammond at skippinet.com.au> writes
> >Robin Boerdijk wrote in message
> >
> >>But you would also expect the .dll of the extension module to be
unloaded
> >>and reloaded so that the state of the .dll is cleared. As Christian
> >>suggests, the .dll somehow doesn't  get unloaded and reloaded an I
wonder
> >if
> >
> ... probably good stuff :)
> >IMO, the _real_ issue is that Python (and/or its modules) are not capable
of
> >being reinitialized without the DLL being "physically" unloaded, and it
> >should be.  It is unclear to me if anything other than ILU is seriously
> >upset that this happens.
> >
> >So the real question is: "yes, this happens, and for good reason.  Who is
it
> >a problem for and why?"
> >
> >[Other than PythonCOM itself probably - this may well cause some leaks in
> >the PythonCOM module init function - which brings me back to a different
> >issue - how does a module know it is being cleaned up by Python?
> >Aaarrrggg... :-]
> >
> yep we discussed this before; I asked then if modules couldn't have
> special named functions apart from __init__ ie __del__ etc. I tried a
> couple of times to use the deletion of globals to check when a module
> was being cleaned up, but it wasn't real reliable.
> >Mark.
> >
> >
>
> --
> Robin Becker










More information about the Python-list mailing list