Again, how to write a cleanup function for a module in C

Lexy Zhitenev zhitenev at
Fri Mar 28 15:19:29 CET 2003

I posted this message a week ago, but didn't get the solution.

I have to do some cleanup when my program exits. It is not global cleanup.
It cannot be done in sys.exitfunc. It is local, I have to manage it in my
module, like closing a connection to the database on exit after connecting
on import.

I've come up to the following solution:

from _ping import ping, unload

class __Cleanup:
    def __del__(self):

__cup = __Cleanup()

Here _ping is a C module, _ping.pyd. I think it needs no commenting. But I
have to use Python wrapper only for deleting!

Is there another way to perform this cleanup?

Regards, Lexy.

More information about the Python-list mailing list