Re: [f2py] Re: unloading/reloading compiled modules
Pearu Peterson <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Hi, The problem of reloading extension modules is well known and AFAIK there is no stable solution for Python extension modules. However, there are ways to avoid reloading extension modules. For example, the extension module should have a name that is unique with respect to its content (the weave solution) and changing the module would mean loading a new extension module. Another way would be to have a master process that calls python as a separate subprocess that carries out computations with f2py generated extension modules. If the extension module is changed then the next subprocess picks up the updated extension module. > Kevin Mitchell a écrit : >> Basically, I want to be able to reload a recompiled Fortran module >> without restarting python. This is more or less essential for using >> python as a development interface. >> >> I understand that what really needs to happen is for the old version >> of the module to first get UNloaded. To this end, I put together the >> following script based on what I found at >> http://stackoverflow.com/questions/359498/how-can-i-unload-a-dll-using-ctypes-in-python >> >> ------------------------------------- >> #!/usr/bin/env python ... >> It segfaults at the second calling of yo.yo(). In fact, it segfaults >> on exit even if I never reload the module. My guess would be that >> something is expecting that library to still be linked, but I have no >> idea where to look or how to change that expectation. If its not >> already obvious from the above script, I should probably mention that >> I'm using Linux and I could care less about platform portability. Try disabling gc. Also, make the python to dump core and use ddd, for example, to investigate what part of the program is giving segfault. HTH, Pearu