Is there a fini procedure for a python module written in C?

I have a python module written in C and I would like to add a function that is called when the module is unloaded. I obviously have a function initfooto initialize the module - is there a way to tell python to call the function finifoowhen it does not initialize the module?

Is there atexitmy only option?

+3
source share
1 answer

Not in Python 2, but Python 3 seems . If you need to manage some resource, I would advise you to place it in a modular object - I am sure that they will be garbage collected when the module is unloaded.


:

, " . Py_Finalize(): .

, , . , , .

+4

Source: https://habr.com/ru/post/1706596/


All Articles