classification
Title: tracemalloc: stop the module later at Python shutdown
Type: Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, neologix, pitrou, python-dev, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2013-11-29 10:57 by vstinner, last changed 2013-12-01 09:05 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
tracemalloc_fini.patch vstinner, 2013-11-29 10:57 review
tracemalloc_fini-2.patch vstinner, 2013-11-29 11:00 review
Messages (4)
msg204717 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-29 10:57
tracemalloc cannot be used in object destructors because the module is stopped early at Python shutdown.

I would like to use tracemalloc.get_object_traceback() in object destructors to retrieve where an object was allocated.

Attached patch replaces the atexit handler with a builtin _PyTraceMalloc_Fini() function to stop tracemalloc much later. It does also simplify the C code of _tracemalloc.c.
msg204718 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-29 11:00
Oh tracemalloc_fini.patch is not correct, _PyTraceMalloc_Fini() should be called after PyImport_Cleanup().
msg204728 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-29 15:25
See also issue19255.
msg204892 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-12-01 09:05
New changeset cc8953ea3c7e by Victor Stinner in branch 'default':
Closes #19831: Stop tracemalloc later at Python shutdown to be able to use
http://hg.python.org/cpython/rev/cc8953ea3c7e
History
Date User Action Args
2013-12-01 09:05:57python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg204892

resolution: fixed
stage: resolved
2013-11-29 21:02:17Arfreversetnosy: + Arfrever
2013-11-29 15:25:59serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg204728
2013-11-29 11:01:00vstinnersetfiles: + tracemalloc_fini-2.patch

messages: + msg204718
2013-11-29 10:57:39vstinnersettitle: tracemalloc: stop the module later -> tracemalloc: stop the module later at Python shutdown
2013-11-29 10:57:31vstinnercreate