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?
initfoo
finifoo
Is there atexitmy only option?
atexit
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(): .
, , . , , .
Source: https://habr.com/ru/post/1706596/More articles:Why won't the Nullable Public Property in the VB.net class accept 0 (zero) as the destination? - vb.nethttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1706592/silverlight-access-to-file-path&usg=ALkJrhiW4ZntCHeJgzHU46nPl4lWyddT8QnSql data output during unit tests - loggingКакое правильное решение для службы авторизации с высокой доступностью? - performanceDelphi: Transparent controls become opaque on netbooks - delphiIs a closed polygon mesh upside down? - algorithmWiFi connection disconnects after a period of inactivity - iphoneWhere can I find sample code or Delphi component for access to exchange contacts and Outlook and meetings? - delphiStrange Rails Routing: two identifiers are swapped in nested resources - ruby-on-railsWhat does the / DISALLOWLIB message mean in VC ++ linker output? - visual-c ++All Articles