atexit handler in IDLE?

S

Steve Spicklemire

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top