Skip to content

Commit

Permalink
fix deadlock in mockPubSub
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed May 13, 2020
1 parent 9a2b157 commit b9b9add
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ func (m *mockPubSub) Subscribe(fn func(fromID string, key string)) error {
func (m *mockPubSub) Publish(fromID, key string) error {
m.calledKeys = append(m.calledKeys, key)
for _, fn := range m.fns {
fn(fromID, key)
// run in goroutine to prevent deadlock
go fn(fromID, key)
log.Println("!!!", fromID, key)
}
return nil
Expand Down

0 comments on commit b9b9add

Please sign in to comment.