File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -306,22 +306,17 @@ func (c *cmdRun) run(cmd *cobra.Command, args []string) (err error) {
306306 // Init has passed successfully, so unless disabled, make sure we send a
307307 // usage report after the context is done.
308308 if ! conf .NoUsageReport .Bool {
309- backgroundProcesses .Add (2 )
310- reportCtx , reportCancel := context .WithCancel (globalCtx )
311- reportDone := make (chan error )
309+ backgroundProcesses .Add (1 )
312310 go func () {
311+ defer backgroundProcesses .Done ()
312+ reportCtx , reportCancel := context .WithTimeout (globalCtx , 3 * time .Second )
313+ defer reportCancel ()
313314 logger .Debug ("Sending usage report..." )
314- reportDone <- reportUsage (reportCtx , execScheduler )
315- close (reportDone )
316- backgroundProcesses .Done ()
317- }()
318- go func () {
319- select {
320- case <- reportDone :
321- case <- time .After (3 * time .Second ):
315+ if rerr := reportUsage (reportCtx , execScheduler ); rerr != nil {
316+ logger .WithError (rerr ).Debug ("Error sending usage report" )
317+ } else {
318+ logger .Debug ("Usage report sent successfully" )
322319 }
323- reportCancel ()
324- backgroundProcesses .Done ()
325320 }()
326321 }
327322
You can’t perform that action at this time.
0 commit comments