amphp / parallel

An advanced parallelization library for PHP, enabling efficient multitasking, optimizing resource use, and application responsiveness through multiple CPU threads.
MIT License
779 stars 64 forks source link

The pool was shut down #195

Closed PNixx closed 6 months ago

PNixx commented 8 months ago

I catch error

\Amp\Parallel\Context\StatusError: The pool was shut down in vendor/amphp/parallel/src/Worker/ContextWorkerPool.php:221

#0 vendor/amphp/parallel/src/Worker/ContextWorkerPool.php(132): Amp\Parallel\Worker\ContextWorkerPool->pull()
#1 src/Process.php(313): Amp\Parallel\Worker\ContextWorkerPool->submit()

To fix the problem, only restarting the process helps. How to automatically restart a worker pool?

trowski commented 8 months ago

Are you receiving this on process shutdown? That's the only reason I can think of why this would be happening outside of explicitly calling shutdown() on ContextWorkerPool.

PNixx commented 8 months ago

I started getting this error when the server ran out of RAM. Even when the memory was freed, the error continued to appear when using a worker pool. Only restarting the service fixed the error.

trowski commented 6 months ago

Came back around to looking at this. My thinking is still the same – something called shutdown() or kill() on the pool instance to cause this exception.

Please take a deeper look at what might be happening here if this is still an issue for you. If you find something, please reopen this issue or create a new one.