Stefan Behnel ha scritto:
Gabriel already pointed you to the module cleanup support in Py3, which can
be used to provide reload capabilities to your module.
In Py2, there are at least some ways to free resources when terminating the
interpreter. See the "atexit" module and the Py_AtExit() function:
http://docs.python.org/library/atexit.html
http://docs.python.org/c-api/sys.html
Note that both have their specific limitations, though, as you can see from
the docs.
Also note that it might help you to take a look at Cython, a Python-to-C
compiler for writing fast C extensions. It has an option for generating
module-level cleanup code automatically, and generally simplifies writing
binary extension modules quite a bit.
Stefan
Thank you very much Stefan for your reply, I'll study the sources you
have pointed me to.
Could I allocate my resources in a "static" object (without publishing
the type of that object so that I can't instantiate another one) linked
to my module?
This way, when I stop the interpreter, the object will be destroyed
calling its destructor.
There's something I'm missing?
Thank you, Luca.
--
http://mail.python.org/mailman/listinfo/python-list