FAQ
I have a goroutine consuming data from a channel and performing some task
with these data. If the goroutine panics (assume I am calling a poorly
written third-party package), what is the Go way of recovering and
restarting the goroutine? In my particular case, loss of data is acceptable
(i.e., dropping the input which caused the panic). Are there any issues
with having the goroutine restart itself inside a defer/recover (see
playground link below)?

http://play.golang.org/p/wpGKWh8u_p

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jesse McNelis at Feb 23, 2014 at 8:14 am

    On 23/02/2014 3:11 PM, "Bill Lattner" wrote:
    Are there any issues with having the goroutine restart itself inside a
    defer/recover?

    The main issue to watch out for is global state that might be in a bad
    state due to the code that panicked.
    Spawned goroutines that might be blocked forever on locks or channel
    communication that will never happen due to the panic.

    It's the same issues you have to look out for in languages with exceptions.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 23, '14 at 4:11a
activeFeb 23, '14 at 8:14a
posts2
users2
websitegolang.org

2 users in discussion

Jesse McNelis: 1 post Bill Lattner: 1 post

People

Translate

site design / logo © 2022 Grokbase