LWN.net Logo

Uses

Uses

Posted Mar 30, 2012 0:36 UTC (Fri) by man_ls (subscriber, #15091)
In reply to: Uses by imgx64
Parent article: Go version 1 released

I don't understand your last paragraph:

Some programmers use recover() to "increase reliability" by catching all possible panics. I find that rather useless, since the whole program will crash if a panic reaches the top of *any goroutine*, and no recover can help. It's usually easier to have a daemon process respawn the program (after logging the crash, of course).
So, can all panics be recovered from, or not? Case in point: I have a Python script which does a complex task and sends an email. If at any point there is an exception, it should also send an email and clean up. Would Go recover() help here?


(Log in to post comments)

Uses

Posted Mar 31, 2012 2:08 UTC (Sat) by imgx64 (guest, #78590) [Link]

You can only recover from panics in the same goroutine. If a panic reaches the top of *any goroutine* without being recovered, the whole program crashes, and you can do nothing about it.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds