atexit handler in IDLE?

Discussion in 'Python' started by Steve Spicklemire, Jan 15, 2013.

  1. Hello Pythonistas!

    I'm trying to get this program, which works on the command line, to run correctly in the IDLE environment:

    import atexit

    print "This is my program"

    def exit_func():
    print "OK.. that's all folks!"

    atexit.register(exit_func)

    print "Program is ending..."


    When I run this on the command line I see:

    This is my program
    Program is ending...
    OK.. that's all folks!

    When I run this in IDLE I see:

    This is my program
    Program is ending...

    But the atexit handler is never called. ;-(

    I tried to fish through the IDLE source to see how the program is actually called, and I decided it looked like it was being invoked with with os.spawnv, but I'm not sure why this would defeat the atexit handler. Anybody know? I'd like to register such a function in my module, but I need it to work in IDLE so that students can easily use it.

    thanks!
    -steve
    Steve Spicklemire, Jan 15, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Hunter

    tkinter idle handler

    John Hunter, Aug 6, 2004, in forum: Python
    Replies:
    1
    Views:
    440
    Michael Hudson
    Aug 6, 2004
  2. Mark Janssen

    atexit handler in IDLE?

    Mark Janssen, Jan 15, 2013, in forum: Python
    Replies:
    0
    Views:
    147
    Mark Janssen
    Jan 15, 2013
  3. Steve Spicklemire

    Re: atexit handler in IDLE?

    Steve Spicklemire, Jan 15, 2013, in forum: Python
    Replies:
    0
    Views:
    146
    Steve Spicklemire
    Jan 15, 2013
  4. Terry Reedy

    Re: atexit handler in IDLE?

    Terry Reedy, Jan 16, 2013, in forum: Python
    Replies:
    0
    Views:
    142
    Terry Reedy
    Jan 16, 2013
  5. David M. Cotter
    Replies:
    1
    Views:
    86
    David M. Cotter
    Jul 30, 2013
Loading...

Share This Page