Hi,
Since I’ve upgraded from php 5.6 to 7 my sleep function become not compatible with pthreads. Ok, why not.
I get this error when I call the sleep function:
An uncaught Exception was encountered
Message: sleep is not suitable for use in multi threaded applications, use synchronized Threaded::wait
If this function was called into a Thread class, I can understand and use Threaded::wait. But here the problem that I call this function from a normal php (not into a Thread object)
From the codeigniter controller class:
public function index()
{
while (true) {
$tasks = $this->checkTask();
$thread = array();
foreach ($tasks as $index => $task) {
while (array_key_exists($index, $thread))
$index = rand(0, 65535);
$thread[$index] = new crwlTasker($task);
$thread[$index]->start();
}
crwlLog("Task launched, wait 60 sec for next check.", 'info', true);
sleep(60);
}
}
And I call this script from this command (CLI) php index.php myclass index
.
Some Information:
php version 7. (RC5)
codeigniter 3.0.2
pthread version 3.0.9
Thank for reading