gearman-go icon indicating copy to clipboard operation
gearman-go copied to clipboard

Waiting until all jobs had been completed

Open ortuman opened this issue 7 years ago • 1 comments

Trying to send N jobs and wait until all of them are completed, is correct to assume that JobHandler will be always called, even when an error occurs?

Currently I'm using a sync.WaitGroup, so in the case that not all of the response handlers are invoked the client could hang forever, and would like to make sure this should never happen.

Thanks in advance, and congrats for the job! :)

ortuman avatar Feb 17 '18 16:02 ortuman

How about using a channel and a goroutine to collect results? JobHandler receives the data and sends to the chan, then you can put a timeout into the select goroutine.

mikespook avatar Feb 19 '18 23:02 mikespook