Executing code at module unload
Lexy Zhitenev
zhitenev at cs.vsu.ru
Tue Mar 18 13:26:49 EST 2003
Hi folks.
I have to write a C module which pings machines using Microsoft ICMP
library.
Unfortunately, 'ping' package written in Python won't work for me. (I can't
create SOCK_RAW sockets).
So, I do WSAStartup, LoadLibrary and etc on import of this module. This is
easy. But I have to call FreeLibrary, WSACleanup when I stop using this
module.
How to accomplish this? In Python I do the following:
...
class __Cleanup:
def __del__(self):
# Cleaning up
pass
__cup = Cleanup()
So, this code is executed in current module scope and only when it is
unloaded. How to do this in C?
Regards, Lexy.
More information about the Python-list
mailing list