Ensure ticker stop

This commit is contained in:
Marwan Sulaiman 2023-05-25 13:52:41 -04:00
parent bfda034655
commit fb13df273a

View File

@ -169,8 +169,10 @@ func (p *Poller) Run(ctx context.Context) (chan Update, error) {
return nil, fmt.Errorf("error initializing poller: %w", p.initErr)
}
tick := time.NewTicker(p.Interval)
defer tick.Stop()
go p.runWithTickChan(ctx, tick.C)
go func() {
defer tick.Stop()
p.runWithTickChan(ctx, tick.C)
}()
return p.c, nil
}