Message 388517 - Python tracker

Message388517

Author gousaiyang
Recipients christian.heimes, docs@python, frankli, gousaiyang, steve.dower, vstinner, zkonge
Date 2021-03-11.19:10:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615489829.21.0.611360303751.issue43438@roundup.psfhosted.org>
In-reply-to
Content
> Please also keep in mind that sys.addaudithook() does **not** add a global hook. The function adds a per-interpreter hook.

Yes, I'm aware of this. And this should be better documented. When I was playing around with audit hooks and reading the source code, I see hooks written in Python (added via sys.addaudithook) are per-interpreter (stored in a Python list object as part of per-interpreter state) while hooks written in C (added via PySys_AddAuditHook) are global (stored in a C linked list). C hooks are more robust. The Python hooks are not inherited in a child process created via multiprocessing when the start method is "spawn" or "forkserver" (not "fork") since they are per-interpreter. I'm not sure whether we should audit the creation of new processes/threads via multiprocessing/threading modules (and also creation of sub-interpreters when PEP 554 gets accepted).
History
Date User Action Args
2021-03-11 19:10:29gousaiyangsetrecipients: + gousaiyang, vstinner, christian.heimes, docs@python, steve.dower, zkonge, frankli
2021-03-11 19:10:29gousaiyangsetmessageid: <1615489829.21.0.611360303751.issue43438@roundup.psfhosted.org>
2021-03-11 19:10:29gousaiyanglinkissue43438 messages
2021-03-11 19:10:29gousaiyangcreate