File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1581,10 +1581,7 @@ func TestGoroutineLeak(t *testing.T) {
1581
1581
ctx , cancel := context .WithCancel (context .Background ())
1582
1582
var wg sync.WaitGroup
1583
1583
wg .Add (1 )
1584
- var subWg sync.WaitGroup
1585
- subWg .Add (1 )
1586
1584
go func () {
1587
- subWg .Done ()
1588
1585
err := db .Subscribe (ctx , func (kvs * pb.KVList ) {
1589
1586
require .Equal (t , []byte ("value" ), kvs .Kv [0 ].GetValue ())
1590
1587
updated = true
@@ -1594,7 +1591,8 @@ func TestGoroutineLeak(t *testing.T) {
1594
1591
require .Equal (t , err .Error (), context .Canceled .Error ())
1595
1592
}
1596
1593
}()
1597
- subWg .Wait ()
1594
+ // Wait for the go routine to be scheduled.
1595
+ time .Sleep (time .Second )
1598
1596
err := db .Update (func (txn * Txn ) error {
1599
1597
return txn .SetEntry (NewEntry ([]byte ("key" ), []byte ("value" )))
1600
1598
})
@@ -1947,6 +1945,8 @@ func ExampleDB_Subscribe() {
1947
1945
log .Printf ("subscription closed" )
1948
1946
}()
1949
1947
1948
+ // Wait for the above go routine to be scheduled.
1949
+ time .Sleep (time .Second )
1950
1950
// Write both keys, but only one should be printed in the Output.
1951
1951
err = db .Update (func (txn * Txn ) error { return txn .Set (aKey , aValue ) })
1952
1952
if err != nil {
You can’t perform that action at this time.
0 commit comments