Calling the Pool() constructor on each iteration leaks the threads,
leading to a "can't start new thread" error during long waits.
This can be aggravated by the constructor being called without an
argument, which by default uses the systems CPU count to create the
pool. When running in a container in a cloud environment this number can
be unexpectedly large (for example, 64).
Reuse the pool and limit the number of threads in the pool.
Calling the Pool() constructor on each iteration leaks the threads,
leading to a "can't start new thread" error during long waits.
This can be aggravated by the constructor being called without an
argument, which by default uses the systems CPU count to create the
pool. When running in a container in a cloud environment this number can
be unexpectedly large (for example, 64).
Reuse the pool and limit the number of threads in the pool.
Signed-off-by: Hunor Csomortáni csomh@redhat.com