<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
2011.04.10. 21:25 keltezéssel, Jason Swails írta:
<blockquote
cite="mid:BANLkTin5ZQFO-t+r=FNEXAnNh9r6r+iW6A@mail.gmail.com"
type="cite"><font color="#000000">Hello everyone,<br>
<br>
This may sound like a bit of a strange desire, but I want to </font>change
the way in which a python program quits if an exception is not
caught. The program has many different classes of exceptions (for
clarity purposes), and they're raised whenever something goes
wrong. Most I want to be fatal, but others I'd want to catch and
deal with.<br>
</blockquote>
Well, the application quits when all of it threads are ended. Do you
want to catch those exception only in the last threads? Or do you
want to do it in all threads? Or just the main thread?<br>
<blockquote
cite="mid:BANLkTin5ZQFO-t+r=FNEXAnNh9r6r+iW6A@mail.gmail.com"
type="cite">Is there any way to control Python's default exit
strategy when it hits an uncaught exception (for instance, call
another function that exits "differently")?<br>
</blockquote>
You can try the atexit module. But I think this is not what you
want. I don't think that exceptions can be intercepted in unusual
ways. "There should be only one obvious way to do it". Can you
please write more about why isn't it good to use try /except?<br>
<blockquote
cite="mid:BANLkTin5ZQFO-t+r=FNEXAnNh9r6r+iW6A@mail.gmail.com"
type="cite"><br>
An obvious way is to just catch every exception and manually call
that function, but then I fill up my script with trys and excepts
which hurts readability (and makes the code uglier) and quashes
tracebacks; neither of which I want to do.<br>
</blockquote>
Okay, so maybe I misunderstood. You where talking about changing the
way in which a python program quits. Can you please come up with an
example and explain your problem in more detail?<br>
<br>
<br />--
<br />This message has been scanned for viruses and
<br />dangerous content by <b>MailScanner</b>, and is
<br />believed to be clean.
</body>
</html>