Live video on the AT Protocol

leak: exponential backoff?

+22 -6
+1 -1
go.mod
··· 18 18 github.com/ThalesGroup/crypto11 v0.0.0-00010101000000-000000000000 19 19 github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d 20 20 github.com/bluesky-social/indigo v0.0.0-20250520232546-236dd575c91e 21 + github.com/cenkalti/backoff/v5 v5.0.2 21 22 github.com/decred/dcrd/dcrec/secp256k1 v1.0.4 22 23 github.com/dunglas/httpsfv v1.0.2 23 24 github.com/ethereum/go-ethereum v1.14.7 ··· 59 60 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 60 61 go.opentelemetry.io/otel/sdk v1.35.0 61 62 go.opentelemetry.io/otel/trace v1.35.0 62 - go.uber.org/goleak v1.3.0 63 63 golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 64 64 golang.org/x/image v0.22.0 65 65 golang.org/x/net v0.39.0
+2
go.sum
··· 147 147 github.com/ccojocar/zxcvbn-go v1.0.2/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60= 148 148 github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= 149 149 github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= 150 + github.com/cenkalti/backoff/v5 v5.0.2 h1:rIfFVxEf1QsI7E1ZHfp/B4DF/6QBAUhmgkxc0H7Zss8= 151 + github.com/cenkalti/backoff/v5 v5.0.2/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= 150 152 github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 151 153 github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= 152 154 github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
+19 -5
pkg/media/leak_test.go
··· 16 16 "time" 17 17 18 18 "github.com/acarl005/stripansi" 19 + "github.com/cenkalti/backoff/v5" 19 20 "github.com/stretchr/testify/require" 20 21 "stream.place/streamplace/pkg/gstinit" 21 22 ) ··· 103 104 os.Exit(m.Run()) 104 105 } 105 106 107 + // Often the GC is instance, but sometimes it takes a while. So, we retry a few times 108 + // with exponential backoff, giving the GC more time to do its thing. 106 109 func getLeakCount(t *testing.T) int { 110 + ticker := backoff.NewTicker(backoff.NewExponentialBackOff()) 111 + defer ticker.Stop() 112 + var leaks int 113 + for i := 0; i < 10; i++ { 114 + leaks = getLeakCountInner(t) 115 + if leaks == 0 { 116 + return leaks 117 + } 118 + if i < 9 { 119 + <-ticker.C 120 + } 121 + } 122 + return leaks 123 + } 124 + 125 + func getLeakCountInner(t *testing.T) int { 107 126 if os.Getenv(IgnoreLeaks) != "" { 108 127 return 0 109 128 } ··· 116 135 117 136 // we want CI to be extra reliable here and a little slower is okay 118 137 flushes := 2 119 - if os.Getenv("CI") != "" { 120 - flushes = 5 121 - } 122 138 123 139 for range flushes { 124 140 ch := make(chan struct{}) ··· 143 159 <-ch 144 160 }() 145 161 } 146 - 147 - time.Sleep(time.Duration(flushes) * time.Second) 148 162 149 163 err = process.Signal(os.Signal(syscall.SIGUSR1)) 150 164 require.NoError(t, err)