Module: Destructor/Cleanup Code/etc

D

Dylan Shell

How do I register a clean up function for a module written in C? While
I can find plenty of documentation for the "init<module_name>"
function... I don't see a single reference on a "done<module_name>" or
something analogous.

Obviously if I can't get code to run in closing time, then the
usefulness is far less (I mean, surely there is a recognition that
some modules will need to clean up after themselves.)

Dylan.
 
A

Alex Martelli

Dylan said:
How do I register a clean up function for a module written in C? While
I can find plenty of documentation for the "init<module_name>"
function... I don't see a single reference on a "done<module_name>" or
something analogous.

Call function register from standard library module atexit, passing it
the Python-callable function object you want to be called at exit,
and optionally positional and keyword arguments you want to be
used when that function is called. I.e., just like for a module written
in Python.


Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,915
Members
47,456
Latest member
JavierWalp

Latest Threads

Top