eventbus: dont panic on closing Subscription twice#3034
Conversation
|
I'm not sure. Why wouldn't this follow the same semantics as closing a channel twice? https://play.golang.com/p/S5frqwAAI1j. That panics, and this seems similar to me. |
|
Not a fan of that decision either. Channel closing twice panics so that it explicitly disallows broken concurrency primitives and avoids race conditions with multiple senders closing the channel. In our case, there's no way to synchronize a subscriber with an emitter. In fact, when dealing with channels, the receiver never closes a channel, it's always the sender who closes the channel because otherwise the sender might panic. Here the subscriber closes the channel. Plus, In almost all cases, the subscriber is closed at the end of the object life time. It seems fine to close it twice with the second one being a no op just like calling Close on a stream twice isn't a panic. |
MarcoPolo
left a comment
There was a problem hiding this comment.
I'm still not convinced by the argument, but I really don't like panics.
|
I don't like them either! |
fixes: #3002