GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — document behavior of calling atexit.register() while atexit._run_exitfuncs is running · Issue #67056 · python/cpython

document behavior of calling atexit.register() while atexit._run_exitfuncs is running #67056

New issue
Copy link
New issue
Copy link
Closed
#104473
Closed
document behavior of calling atexit.register() while atexit._run_exitfuncs is running#67056
#104473
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@smontanaro
smontanaro
opened on Nov 13, 2014
Issue body actions
BPO 22867
Nosy @smontanaro, @vadmium

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2014-11-13.20:52:37.164>
labels = ['docs']
title = 'document behavior of calling atexit.register() while atexit._run_exitfuncs is running'
updated_at = <Date 2015-07-21.07:43:20.900>
user = 'https://github.com/smontanaro'

bugs.python.org fields:

activity = <Date 2015-07-21.07:43:20.900>
actor = 'ethan.furman'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2014-11-13.20:52:37.164>
creator = 'skip.montanaro'
dependencies = []
files = []
hgrepos = []
issue_num = 22867
keywords = []
message_count = 2.0
messages = ['231135', '231354']
nosy_count = 3.0
nosy_names = ['skip.montanaro', 'docs@python', 'martin.panter']
pr_nums = []
priority = 'low'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue22867'
versions = []

Linked PRs

  • gh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined #104473
  • [3.11] gh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined (GH-104473) #104500

Activity

  1. smontanaro commented on Nov 13, 2014

    @smontanaro
    smontanaro
    on Nov 13, 2014
    ContributorAuthor
    More actions

    A discussion on comp.lang.python about prettying up the "if __name__ == 'main__'" idiom led to a suggestion that a decorator could simple register the main function using atexit.register. That looks like it will work, but leaves open the possibility that while main() is running via atexit._run_exitfuncs, other exit functions might be registered.

    As currently defined (at least in the Python version with 2.7), I think everything will work fine. Still, the behavior of adding new exit functions during exit is not defined. Would be kind of nice if this behavior was blessed, and then mentioned in the documentation.

  2. smontanaro
    assigned
    docspython
    on Nov 13, 2014
  3. smontanaro
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Nov 13, 2014
  4. ethanfurman commented on Nov 19, 2014

    @ethanfurman
    ethanfurman
    on Nov 19, 2014
    Member
    More actions

    From a post by Ian Kelly (https://mail.python.org/pipermail/python-list/2014-November/681073.html)
    --------------------------------------------------------------
    In fact it seems the behavior does differ between Python 2.7 and Python 3.4:

    $ cat testatexit.py
    import atexit
    
    @atexit.register
    def main():
      atexit.register(goodbye)
    
    @atexit.register
    def goodbye():
      print("Goodbye")
    $ python2 testatexit.py
    Goodbye
    Goodbye
    $ python3 testatexit.py
    Goodbye
  5. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  6. iritkatriel commented on May 13, 2023

    @iritkatriel
    iritkatriel
    on May 13, 2023
    Member
    More actions

    The atexit functions are invoked in LIFO order, so I think it's not a good idea to add more after the first one started running. We don't currently forbid, it and I wouldn't argue in favour of doing so, but we shouldn't encourage it.

  7. smontanaro commented on May 13, 2023

    @smontanaro
    smontanaro
    on May 13, 2023
    ContributorAuthor
    More actions

    This has been idle for "awhile." Should we just put our heads together and decide how best to document this behavior?

    Reacted by Irit Katriel
  8. iritkatriel commented on May 13, 2023

    @iritkatriel
    iritkatriel
    on May 13, 2023
    Member
    More actions

    I'm not sure what the behaviour is. Or rather, what behaviour we want to commit to.

  9. smontanaro commented on May 14, 2023

    @smontanaro
    smontanaro
    on May 14, 2023
    ContributorAuthor
    More actions

    I'm not sure that committing to any particular behavior is the right thing to do without some more discussion. Maybe just warn that calling atexit.register after _PyAtExit_Call has been invoked is undefined. There's no mention of that corner case in the 3.11 or 3.12 documentation as it stands.

    Reacted by Irit Katriel
  10. iritkatriel
    added 2 commits that reference this issue on May 14, 2023

    pythongh-67056: document that registering/unregistering an atexit fun…

    d3127cd

    Revert "pythongh-67056: document that registering/unregistering an at…

    e23c17b
  11. iritkatriel
    closed this as completedin #104473on May 15, 2023
  12. iritkatriel
    added a commit that references this issue on May 15, 2023

    gh-67056: document that registering/unregistering an atexit func from…

    b15a1a6
  13. miss-islington
    added a commit that references this issue on May 15, 2023

    pythongh-67056: document that registering/unregistering an atexit fun…

    6ade9ea
  14. iritkatriel
    added a commit that references this issue on May 15, 2023

    [3.11] gh-67056: document that registering/unregistering an atexit fu…

    a712c5f
  15. carljm
    added 2 commits that reference this issue on May 15, 2023

    Merge branch 'main' into supermon

    343867a

    Merge branch 'main' into cached_property_docs

    452d9f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.