[Tutor] exit handler for C extension module

Shuying Wang shuying at gmail.com
Mon Jan 18 08:58:41 CET 2010


I found what I was after, right after I posted to this list. It's
Py_AtExit. I'm accessing an old, unsupported database using it's C
API. I've tried using Cython but found it hard to get my head around
and I'm finding it somewhat easier to just write by hand.

On Mon, Jan 18, 2010 at 6:40 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> What would be an atexit equivalent for a C extension module? When my
>> extension module is unloaded, I would like some clean up functions to
>> be called from an external c library. I've had a look at the C
>> extension guide but I can't find anything like that,
>
> I'm not aware of anything special here. Just use the "atexit" module itself
> and register a Python function. At least, that's what we do in Cython for
> any module level cleanup.
>
> You may also consider adding some hints on what you want to use it for,
> maybe there is some support for your actual use case.
>
> Stefan


More information about the Tutor mailing list