WyriHaximus / reactphp-child-process-pool

MIT License
40 stars 9 forks source link

FlexiblePool ttl closes under MIN_SIZE workers #44

Open woytam opened 4 years ago

woytam commented 4 years ago

Hi, I have found out, that Pool\Flexible with TTL closes processes under the count of Options:MIN_SIZE. Example:

$options = [
    Options::MIN_SIZE   => 1,
    Options::MAX_SIZE   => 5,
    Options::TTL        => 10,      // seconds
];
Flexible::create(new Process('exec php ...'), $loop, $options);

Pool starts with 1 worker, but after 10 seconds (Options::TTL) of inactivity, worker is closed and there is 0 workers at that time. Problem can be in function ttl, but I do not understand the logic of this function to make PR.

WyriHaximus commented 4 years ago

Ow that's interesting, let me dig into it and give you some pointers on how to test this if you'd like to make the PR. Or you can already make the PR with just the test for this and I'll give you the pointers on how to proceed.