[issue9788] atexit and execution order
Éric Araujo mer...@netwok.org added the comment: Reopened as #15233. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset e37fa30c4be4 by Éric Araujo in branch '3.2': Document that atexit execution order is undefined (#9788) http://hg.python.org/cpython/rev/e37fa30c4be4 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset df415bfbb652 by Éric Araujo in branch '2.7': Document that atexit execution order is undefined (#9788) http://hg.python.org/cpython/rev/df415bfbb652 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Éric Araujo mer...@netwok.org added the comment: Given Benjamin and Giampaolo’s support, I committed my patch, so that at least the current behavior is documented. I personally have no opinion on LIFO vs. FIFO vs. undefined; I just think that the atexit module is not a wrapper around C’s atexit, and as such not bound by the same rules, and undefined sounds fine. If you feel very strongly about that, then please follow up on python-dev. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Giampaolo Rodola' g.rod...@gmail.com added the comment: Thanks. After all, I think that keeping atexit simple is the best solution and a doc adjustement is just fine. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Éric Araujo mer...@netwok.org added the comment: Here’s a patch. -- keywords: +needs review, patch resolution: accepted - stage: needs patch - patch review versions: +Python 3.3 -Python 3.1 Added file: http://bugs.python.org/file22318/doc-atexit-order-undefined.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Charles-François Natali neolo...@free.fr added the comment: I don't think the order should be defined. I disagree. The C standard explicitely states that the functions are called in LIFO order (which is the natural order in this case). The current implementation guarantees LIFO order, I think it should be documented. -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Changes by Skip Montanaro s...@pobox.com: -- nosy: -skip.montanaro ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Meador Inge mead...@gmail.com added the comment: I agree with Antoine's LIFO comment. Also, FWIW, the C standard library behaves in a LIFO manner as well (C99 spec - 7.20.4.3 clause 3): First, all functions registered by the atexit function are called, in the reverse order of their registration,253) except that a function is called after any previously registered functions that had already been called at the time it was registered. If, during the call to any such function, a call to the longjmp function is made that would terminate the call to the registered function, the behavior is undefined. -- nosy: +meador.inge ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
New submission from Giampaolo Rodola' g.rod...@gmail.com: import atexit @atexit.register def goodbye1(): print(1) @atexit.register def goodbye2(): print(2) The code above prints: 2 1 ...that is, the last registered function is executed first. Wouldn't the contrary be better? -- components: Library (Lib) messages: 115747 nosy: giampaolo.rodola priority: normal severity: normal status: open title: atexit and execution order versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Skip Montanaro s...@pobox.com added the comment: I'm sure you can craft cases where one order is preferable to another, but I don't think you can make the case in general that first in, first out is preferable to last in, first out, or any other ordering of exit functions. -- nosy: +skip.montanaro ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Giampaolo Rodola' g.rod...@gmail.com added the comment: I think it's not a matter of preferable but most expected and I see FIFO as the most expected behavior in this case. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Antoine Pitrou pit...@free.fr added the comment: LIFO looks preferable if you want your setup/teardown code to be properly nested (that is, if I set up A before B, I want B to be torn down before A). -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Éric Araujo mer...@netwok.org added the comment: It seems to me that atexit is simple by design: It registers callables that do one thing, period. If you have dependencies in your cleanup code, you should write a function doing the Right Thing™ and register that. This keeps the implementation simple, otherwise we’d have to debate LIFO vs. FIFO, adding an argument to register vs. exposing the list of callables, etc. If you agree, I could make a patch to make the docs more explicit about atexit’s simplicity and lack of guarantee about run order. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Benjamin Peterson benja...@python.org added the comment: I don't think the order should be defined. -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Giampaolo Rodola' g.rod...@gmail.com added the comment: Ok, I'll shut up then. =) If you agree, I could make a patch to make the docs more explicit about atexit’s simplicity and lack of guarantee about run order. Sure, go ahead. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9788] atexit and execution order
Changes by Éric Araujo mer...@netwok.org: -- assignee: - eric.araujo components: +Documentation -Library (Lib) resolution: - accepted stage: - needs patch versions: +Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9788 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com