prometheus-community / pro-bing

A library for creating continuous probers
MIT License
291 stars 49 forks source link

func `RunWithContext` didn't exit as expected #64

Open ruokeqx opened 10 months ago

ruokeqx commented 10 months ago
// RunWithContext runs the pinger with a context. This is a blocking function that will exit when it's
// done or if the context is canceled. If Count or Interval are not specified, it will run continuously until
// it is interrupted.
func (p *Pinger) RunWithContext(ctx context.Context) error {
...
    if p.ipaddr == nil {
        err = p.Resolve()
    }
...
    return p.run(ctx, conn)
}

function RunWithContext didn't exit as expected as it will block in p.Resolve(), it didn't exit even when ctx is canceled before it was passed in

thediveo commented 2 months ago

A workaround is to use p.ResolveTimeout for the moment, yet IMHO this should be fixed to use resolve using the passed context.