While using AMPHP libraries for thread working tasks, I suddenly got the Warning and Error:
PHP Warning: include(/.../vendor/amphp/process/lib/ProcessException.php): failed to open stream: Too many open files in /.../vendor/composer/ClassLoader.php on line 445
PHP Fatal error: Uncaught Error: Class 'Amp\Failure' not found
This was previously working fine, and started to get the issue recently.
Using:
- PHP 7.4.21 (cli)
- macOS
- "amphp/parallel-functions": "^1.0"
According to a thread on AMPHP GitHub issue page: https://github.com/amphp/parallel-functions/issues/22
On macOS, the ulimit is by default 1024.
In my case, upgrading that to
ulimit -n 4096as suggested, worked fine.According to IBM docs: "ulimit sets or displays the resource limits on processes created by the user." More info.