Éric Araujo mer...@netwok.org added the comment:
Reopened as #15233.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9788
___
___
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
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
É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
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
É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
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
Changes by Skip Montanaro s...@pobox.com:
--
nosy: -skip.montanaro
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9788
___
___
Python-bugs-list
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
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?
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:
Changes by Éric Araujo mer...@netwok.org:
--
nosy: +eric.araujo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9788
___
___
Python-bugs-list
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
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
É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
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
___
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
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
18 matches
Mail list logo