unloading extension library
fredrik at pythonware.com
Wed Oct 18 21:45:43 CEST 2006
Bill Pursell wrote:
>>>> del sys.modules["spam"]
>>>> del spam
> Should remove all the references, but I still don't want to wait for
> garbage collection. I need to be sure that the dlclose() happens
> and the destructors are called. Can I do that? (without relying
> on ctypes, preferrably.)
in general, no. Python's not C++; you cannot rely on the garbage
collector to release resources at a given time (or to release them at
all, for that matter).
if you want to tear down an object or a module in a reliable fashion,
you need to provide an API for that purpose.
More information about the Python-list