Re: [capi-sig] How do I get the Objects to clean up after a python script exits?
15 Dec
2012
15 Dec
'12
7:31 a.m.
Robert Steckroth, 12.12.2012 19:45:
When I test my module in the interpreter it automatically cleans up any created objects. This is a very nice feature for my module and I would like to use it. How do I go about getting my scripts to send an exit cleanup single?
Depends on exactly what you are trying to achieve, but you might want to look at the atexit module.
Py3 additionally has the PyModuleDef setup which allows you to clean up module globals at exactly the right time on interpreter tear down. It basically implements garbage collection for modules.
(Shameless hint: Cython cleans up global variables for you automatically and chooses the right way to do so based on the capabilities of the current runtime.)
Stefan
4149
Age (days ago)
4149
Last active (days ago)
0 comments
1 participants
participants (1)
-
Stefan Behnel