panic: send on closed channel, when lots of goroutine are running(may be for a long time)
guest6379 opened this issue · comments
guest6379 commented
I'm not quite sure when this issue will happen, but it throws exception as below:
panic: send on closed channel
goroutine 712 [running]:
github.com/alitto/pond.(*WorkerPool).submit(0xc091f93a40, 0xc000536720, 0x1)
/home/ubuntu/gomods/pkg/mod/github.com/alitto/pond@v1.8.3/pond.go:277 +0x265
github.com/alitto/pond.(*WorkerPool).Submit(...)
/home/ubuntu/gomods/pkg/mod/github.com/alitto/pond@v1.8.3/pond.go:222
demofiles.Download.func6(0x2?, 0xc000452b60?, 0xc0005fe900?, {0xc000597000, 0x5db, 0x700})
/home/ubuntu/project1/files/download.go:837 +0x121d
created by demofiles.Download
/home/ubuntu/project1/files/download.go:820 +0x2125
exit status 2
// Submit the task to the tasks channel and wait for it to be picked up by a worker
p.tasks <- task
submitted = true
return
Alejandro Durante commented
Hey @guest6379, if you could provide the code you are using and presents this exception that would be great, to find the root cause.
The channel in p.tasks
gets closed only when the pool is stopped by calling any of these methods: Stop
, StopAndWait
or StopAndWaitFor
. The error you are seeing may indicate some tasks are being submitted after the pool is stopped. The general recommendation is to stop submitting tasks to the pool before stopping the worker pool, to avoid these errors.
Alejandro Durante commented
Closing due to inactivity