Dynamically reloading extension modules

Ken Seehof kens at sightreader.com
Wed Mar 21 18:38:34 EST 2001


Not exactly.  I didn't state the problem very clearly.  The
problem is that while an extension module is loaded, the
module file (pyd on windows) is read-only.

At least this is true on windows.  On unix, I think maybe you
can rename the module file, rebuild it, and do a reload(module).
Is this true?  Windows doesn't allow you to rename or rewrite
a dll while it is in use, so something like FreeLibrary would be
necessary.

"Timothy Grant" <tjg at exceptionalminds.com> says:
> On Wed, Mar 21, 2001 at 02:01:44PM -0800, Ken Seehof wrote:
> > Has anyone found a technique for dynamically unloading and
> > reloading an extension module?  I want to be able to modify,
> > build, and reload an extension module from within my program.
> > 
> > Unfortunately python apparently doesn't use FreeLibrary when
> > a module object is released.  Maybe I can do some kind of
> > hack to call FreeLibrary explicitly.  Is there a way to do this that
> > is portable?
> 
> I'm not sure I know what your asking, but does
> 
> reload(modulename) fit the bill?

----------------------------------------------------
Copyright (c) 2001 by Ken Seehof
This document may not be distributed, copied,
duplicated, or replicated in any form without
express written permission by Ken Seehof.
Express permission is hereby granted.
kens at neuralintegrator.com
----------------------------------------------------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20010321/934ddb4d/attachment.html>


More information about the Python-list mailing list