Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20438
| Date | 2012-02-15 13:12 +0000 |
|---|---|
| From | Andrea Crotti <andrea.crotti.0@gmail.com> |
| Subject | atexit.register in case of errors |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5827.1329311531.27778.python-list@python.org> (permalink) |
I have the following very simplified situation
from atexit import register
def goodbye():
print("saying goodbye")
def main():
while True:
var = raw_input("read something")
if __name__ == '__main__':
register(goodbye)
main()
But in my case the "goodbye" function is deleting the logging file which
was created
during the application execution.
Now the problem is that it *always* executes, even when the applications
quits for
some bad errors.
Is there a way to have an exit hook, which doesn't execute in case of
errors?
I've seen the code of atexit and it apparently doesn't know anything
about the current
status and why the application is actually quitting, is that correct?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
atexit.register in case of errors Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-15 13:12 +0000
Re: atexit.register in case of errors Mel Wilson <mwilson@the-wire.com> - 2012-02-15 08:33 -0500
Re: atexit.register in case of errors Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-02-15 08:52 -0500
Re: atexit.register in case of errors Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-02-15 16:18 +0100
Re: atexit.register in case of errors Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-15 15:41 +0000
Re: atexit.register in case of errors Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-02-15 14:35 +0000
Re: atexit.register in case of errors Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-15 10:40 -0800
Re: atexit.register in case of errors Miki Tebeka <miki.tebeka@gmail.com> - 2012-02-15 10:40 -0800
csiph-web